pub trait Transport:
Debug
+ Send
+ Sync {
type Acceptor: Send + Sync;
type RawStream: Send + Sync;
type Stream: 'static + AsyncRead + AsyncWrite + ProtobufStream + Unpin + Send + Sync + Debug;
// Required methods
fn new(config: &TransportConfig) -> Result<Self>
where Self: Sized;
fn as_raw_fd(conn: &Self::Stream) -> RawFd;
fn hint(conn: &Self::Stream, opts: SocketOpts);
fn bind<'life0, 'async_trait>(
&'life0 self,
addr: NamedSocketAddr,
) -> Pin<Box<dyn Future<Output = Result<Self::Acceptor>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn accept<'life0, 'life1, 'async_trait>(
&'life0 self,
a: &'life1 Self::Acceptor,
) -> Pin<Box<dyn Future<Output = Result<(Self::RawStream, SocketAddr)>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn handshake<'life0, 'async_trait>(
&'life0 self,
conn: Self::RawStream,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 AddrMaybeCached,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn get_header(&self, _name: &str) -> Option<String> { ... }
}Expand description
Specify a transport layer, like TCP, TLS
Required Associated Types§
type Acceptor: Send + Sync
type RawStream: Send + Sync
type Stream: 'static + AsyncRead + AsyncWrite + ProtobufStream + Unpin + Send + Sync + Debug
Required Methods§
fn new(config: &TransportConfig) -> Result<Self>where
Self: Sized,
Sourcefn as_raw_fd(conn: &Self::Stream) -> RawFd
fn as_raw_fd(conn: &Self::Stream) -> RawFd
Get the stream id, which is used to identify the transport layer
Sourcefn hint(conn: &Self::Stream, opts: SocketOpts)
fn hint(conn: &Self::Stream, opts: SocketOpts)
Provide the transport with socket options, which can be handled at the need of the transport
fn bind<'life0, 'async_trait>(
&'life0 self,
addr: NamedSocketAddr,
) -> Pin<Box<dyn Future<Output = Result<Self::Acceptor>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn accept<'life0, 'life1, 'async_trait>(
&'life0 self,
a: &'life1 Self::Acceptor,
) -> Pin<Box<dyn Future<Output = Result<(Self::RawStream, SocketAddr)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn accept<'life0, 'life1, 'async_trait>(
&'life0 self,
a: &'life1 Self::Acceptor,
) -> Pin<Box<dyn Future<Output = Result<(Self::RawStream, SocketAddr)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
accept must be cancel safe
fn handshake<'life0, 'async_trait>(
&'life0 self,
conn: Self::RawStream,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'life1, 'async_trait>(
&'life0 self,
addr: &'life1 AddrMaybeCached,
) -> Pin<Box<dyn Future<Output = Result<Self::Stream>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
fn get_header(&self, _name: &str) -> Option<String>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.