pub trait TransportImplHelper {
type Stream: AsyncRead + AsyncWrite + StreamOps + Send + Sync + 'static;
// Required method
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 OwnedChanTarget,
) -> Pin<Box<dyn Future<Output = Result<(OwnedChanTarget, Self::Stream)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}
Expand description
A convenient API for defining transports for use in Tor and elsewhere.
This type’s role is to let the implementor just define a replacement way to pass bytes around, and return something that we can use in place of a TcpStream.
This is the trait you should probably implement if you want to define a new
ChannelFactory
that performs Tor over
TLS over some stream-like type, and you only want to define the stream-like
type.
To convert a TransportImplHelper
into a
ChannelFactory
, wrap it in a
ChanBuilder
.
Required Associated Types§
Required Methods§
Sourcefn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 OwnedChanTarget,
) -> Pin<Box<dyn Future<Output = Result<(OwnedChanTarget, Self::Stream)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
target: &'life1 OwnedChanTarget,
) -> Pin<Box<dyn Future<Output = Result<(OwnedChanTarget, Self::Stream)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Implements the transport: make a TCP connection (possibly tunneled over whatever protocol) if possible.
This method does does not necessarily handle retries or timeouts, although some of its implementations may.
This method does not necessarily handle every kind of transport. If the
caller provides a target with the wrong
TransportId
, this method should return
Error::NoSuchTransport
.