mirror of
https://github.com/Noratrieb/101844-repro.git
synced 2026-01-14 14:25:02 +01:00
help
This commit is contained in:
parent
0241ea2615
commit
292ba1a477
1 changed files with 12 additions and 25 deletions
|
|
@ -1,8 +1,5 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::{
|
use std::pin::Pin;
|
||||||
pin::Pin,
|
|
||||||
task::{Context, Poll},
|
|
||||||
};
|
|
||||||
|
|
||||||
use core::ops::DerefMut;
|
use core::ops::DerefMut;
|
||||||
|
|
||||||
|
|
@ -10,10 +7,6 @@ pub trait Stream {
|
||||||
type Item;
|
type Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: ?Sized + Stream + Unpin> Stream for &mut S {
|
|
||||||
type Item = S::Item;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<P> Stream for Pin<P>
|
impl<P> Stream for Pin<P>
|
||||||
where
|
where
|
||||||
P: DerefMut + Unpin,
|
P: DerefMut + Unpin,
|
||||||
|
|
@ -24,18 +17,16 @@ where
|
||||||
|
|
||||||
pub trait TryStream: Stream {
|
pub trait TryStream: Stream {
|
||||||
type Ok;
|
type Ok;
|
||||||
type Error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, T, E> TryStream for S
|
impl<S, T> TryStream for S
|
||||||
where
|
where
|
||||||
S: ?Sized + Stream<Item = Result<T, E>>,
|
S: ?Sized + Stream<Item = T>,
|
||||||
{
|
{
|
||||||
type Ok = T;
|
type Ok = T;
|
||||||
type Error = E;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type BoxError = Box<dyn std::error::Error + Send + Sync>;
|
pub type BoxError = ();
|
||||||
|
|
||||||
pub trait Discover {
|
pub trait Discover {
|
||||||
type Key;
|
type Key;
|
||||||
|
|
@ -43,14 +34,14 @@ pub trait Discover {
|
||||||
type Error;
|
type Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K, S, E, D: ?Sized> Discover for D
|
impl<K, S, D: ?Sized> Discover for D
|
||||||
where
|
where
|
||||||
D: TryStream<Ok = (K, S), Error = E>,
|
D: TryStream<Ok = (K, S)>,
|
||||||
K: Eq,
|
K: Eq,
|
||||||
{
|
{
|
||||||
type Key = K;
|
type Key = K;
|
||||||
type Service = S;
|
type Service = S;
|
||||||
type Error = E;
|
type Error = ();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Service<Request> {
|
pub trait Service<Request> {
|
||||||
|
|
@ -96,13 +87,13 @@ impl<MS, Target, Request> Stream for PoolDiscoverer<MS, Target, Request>
|
||||||
where
|
where
|
||||||
MS: MakeService<Target, Request>,
|
MS: MakeService<Target, Request>,
|
||||||
{
|
{
|
||||||
type Item = Result<(usize, DropNotifyService<MS::Service>), MS::Error>;
|
type Item = (usize, DropNotifyService<MS::Service>);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Builder {}
|
pub struct Builder {}
|
||||||
|
|
||||||
impl Builder {
|
impl Builder {
|
||||||
pub fn build<MS, Target, Request>() -> ()
|
pub fn build<MS, Target, Request>()
|
||||||
where
|
where
|
||||||
MS: MakeService<Target, Request>,
|
MS: MakeService<Target, Request>,
|
||||||
MS::Error: Into<crate::BoxError>,
|
MS::Error: Into<crate::BoxError>,
|
||||||
|
|
@ -110,9 +101,7 @@ impl Builder {
|
||||||
let d: PoolDiscoverer<MS, Target, Request> = todo!();
|
let d: PoolDiscoverer<MS, Target, Request> = todo!();
|
||||||
|
|
||||||
// THE CRITICAL STATEMENT
|
// THE CRITICAL STATEMENT
|
||||||
let x = Balance::new(Box::pin(d));
|
let _ = Balance::new(Box::pin(d));
|
||||||
|
|
||||||
todo!()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,16 +109,14 @@ pub struct Pool<MS, Target, Request> {
|
||||||
balance: (MS, Target, Request),
|
balance: (MS, Target, Request),
|
||||||
}
|
}
|
||||||
|
|
||||||
type PinBalance<S, Request> = Balance<Pin<Box<S>>, Request>;
|
|
||||||
|
|
||||||
impl<MS, Target, Req> Service<Req> for Pool<MS, Target, Req>
|
impl<MS, Target, Req> Service<Req> for Pool<MS, Target, Req>
|
||||||
where
|
where
|
||||||
MS: MakeService<Target, Req>,
|
MS: MakeService<Target, Req>,
|
||||||
MS::Error: Into<crate::BoxError>,
|
MS::Error: Into<crate::BoxError>,
|
||||||
Target: Clone,
|
Target: Clone,
|
||||||
{
|
{
|
||||||
type Error = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Error;
|
type Error = <Balance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Error;
|
||||||
type Future = <PinBalance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Future;
|
type Future = <Balance<PoolDiscoverer<MS, Target, Req>, Req> as Service<Req>>::Future;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DropNotifyService<Svc> {
|
pub struct DropNotifyService<Svc> {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue