pub trait TransportExt: Transport {
    // Provided methods
    fn boxed(self) -> BoxedTransport<Self::Output, Self::Error>
       where Self: Sized + Send + 'static,
             Self::Listener: Send + 'static,
             Self::Inbound: Send + 'static,
             Self::Outbound: Send + 'static { ... }
    fn and_then<F, Fut, O>(self, f: F) -> AndThen<Self, F>
       where Self: Sized,
             F: FnOnce(Self::Output, NetworkAddress, ConnectionOrigin) -> Fut + Clone,
             Fut: Future<Output = Result<O, Self::Error>> { ... }
}
Expand description

An extension trait for Transports that provides a variety of convenient combinators.

Additional protocols or functionality can be layered on top of an existing Transport by using this extension trait. For example, one might want to take a raw connection and upgrade it to a secure transport followed by version handshake by chaining calls to and_then. Each method yields a new Transport whose connection setup incorporates all earlier upgrades followed by the new upgrade, i.e. the order of the upgrades is significant.

Provided Methods§

source

fn boxed(self) -> BoxedTransport<Self::Output, Self::Error>where Self: Sized + Send + 'static, Self::Listener: Send + 'static, Self::Inbound: Send + 'static, Self::Outbound: Send + 'static,

Turns a Transport into an abstract boxed transport.

source

fn and_then<F, Fut, O>(self, f: F) -> AndThen<Self, F>where Self: Sized, F: FnOnce(Self::Output, NetworkAddress, ConnectionOrigin) -> Fut + Clone, Fut: Future<Output = Result<O, Self::Error>>,

Applies a function producing an asynchronous result to every connection created by this transport.

This function can be used for ad-hoc protocol upgrades on a transport or for processing or adapting the output of an earlier upgrade. The provided function must take as input the output from the existing transport and a ConnectionOrigin which can be used to identify the origin of the connection (inbound vs outbound).

Implementors§

source§

impl<T> TransportExt for Twhere T: Transport + ?Sized,