pub trait ClientProto<T: 'static>: 'static {
type Request: 'static;
type Response: 'static;
type Transport: 'static + Stream<Item = Self::Response, Error = Error> + Sink<SinkItem = Self::Request, SinkError = Error>;
type BindTransport: IntoFuture<Item = Self::Transport, Error = Error>;
// Required method
fn bind_transport(&self, io: T) -> Self::BindTransport;
}
Expand description
A pipelined client protocol.
The T
parameter is used for the I/O object used to communicate, which is
supplied in bind_transport
.
For simple protocols, the Self
type is often a unit struct. In more
advanced cases, Self
may contain configuration information that is used
for setting up the transport in bind_transport
.
Required Associated Types§
Sourcetype Transport: 'static + Stream<Item = Self::Response, Error = Error> + Sink<SinkItem = Self::Request, SinkError = Error>
type Transport: 'static + Stream<Item = Self::Response, Error = Error> + Sink<SinkItem = Self::Request, SinkError = Error>
The message transport, which works with I/O objects of type T
.
An easy way to build a transport is to use tokio_core::io::Framed
together with a Codec
; in that case, the transport type is
Framed<T, YourCodec>
. See the crate docs for an example.
Sourcetype BindTransport: IntoFuture<Item = Self::Transport, Error = Error>
type BindTransport: IntoFuture<Item = Self::Transport, Error = Error>
A future for initializing a transport from an I/O object.
In simple cases, Result<Self::Transport, Self::Error>
often suffices.
Required Methods§
Sourcefn bind_transport(&self, io: T) -> Self::BindTransport
fn bind_transport(&self, io: T) -> Self::BindTransport
Build a transport from the given I/O object, using self
for any
configuration.
An easy way to build a transport is to use tokio_core::io::Framed
together with a Codec
; in that case, bind_transport
is just
io.framed(YourCodec)
. See the crate docs for an example.