pub trait MakeTransport<Target, Request>: Sealed<Target, Request> {
type Item;
type Error;
type SinkError;
type Transport: TryStream<Ok = Self::Item, Error = Self::Error> + Sink<Request, Error = Self::SinkError>;
type MakeError;
type Future: Future<Output = Result<Self::Transport, Self::MakeError>>;
// Required methods
fn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::MakeError>>;
fn make_transport(&mut self, target: Target) -> Self::Future;
}
Expand description
Creates new Transport
(i.e., Sink + Stream
) instances.
Acts as a transport factory. This is useful for cases where new Sink + Stream
values must be produced.
This is essentially a trait alias for a Service
of Sink + Stream
s.
Required Associated Types§
Required Methods§
Sourcefn poll_ready(
&mut self,
cx: &mut Context<'_>,
) -> Poll<Result<(), Self::MakeError>>
fn poll_ready( &mut self, cx: &mut Context<'_>, ) -> Poll<Result<(), Self::MakeError>>
Returns Ready
when the factory is able to create more transports.
If the service is at capacity, then NotReady
is returned and the task
is notified when the service becomes ready again. This function is
expected to be called while on a task.
This is a best effort implementation. False positives are permitted.
It is permitted for the service to return Ready
from a poll_ready
call and the next invocation of make_transport
results in an error.
Sourcefn make_transport(&mut self, target: Target) -> Self::Future
fn make_transport(&mut self, target: Target) -> Self::Future
Create and return a new transport asynchronously.