pub trait Transport: Send + 'static {
    type Body: Body;
    type Info: Clone + Send + 'static;
    type Config: Clone + Default + Send + Sync + 'static;
    type ReadHalf<'a>: TransportReadHalf<Body = Self::Body> + 'a;
    type WriteHalf<'a>: TransportWriteHalf<Body = Self::Body> + 'a;

    // Required methods
    fn split(&mut self) -> (Self::ReadHalf<'_>, Self::WriteHalf<'_>);
    fn info(&self) -> Result<Self::Info>;
}
Expand description

Trait for types that represent a bi-direction message transport.

Note that you can not use the transport itself directly. Instead, you must split it in a read and write half and use those.

Required Associated Types§

source

type Body: Body

The body type for the messages.

source

type Info: Clone + Send + 'static

Information about the underlying stream or connection of the transport.

source

type Config: Clone + Default + Send + Sync + 'static

The configuration type for the transport.

source

type ReadHalf<'a>: TransportReadHalf<Body = Self::Body> + 'a

The type of the read half of the transport.

source

type WriteHalf<'a>: TransportWriteHalf<Body = Self::Body> + 'a

The type of the write half of the transport.

Required Methods§

source

fn split(&mut self) -> (Self::ReadHalf<'_>, Self::WriteHalf<'_>)

Split the transport into a read half and a write half.

source

fn info(&self) -> Result<Self::Info>

Get information about the peer on the other end of the transport.

For TCP streams, this includes a socket address with an IP address and port number. For Unix streams and seqpacket streams this includes the credentials of the remote process.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Transport for StreamTransport<TcpStream>

§

type Body = StreamBody

§

type Info = TcpStreamInfo

§

type Config = StreamConfig

§

type ReadHalf<'a> = StreamReadHalf<ReadHalf<'a>>

§

type WriteHalf<'a> = StreamWriteHalf<WriteHalf<'a>>

source§

impl Transport for StreamTransport<UnixStream>

§

type Body = StreamBody

§

type Info = UnixStreamInfo

§

type Config = StreamConfig

§

type ReadHalf<'a> = StreamReadHalf<ReadHalf<'a>>

§

type WriteHalf<'a> = StreamWriteHalf<WriteHalf<'a>>

source§

impl Transport for UnixTransport<UnixSeqpacket>

§

type Body = UnixBody

§

type Info = UnixSeqpacketInfo

§

type Config = UnixConfig

§

type ReadHalf<'a> = UnixReadHalf<&'a UnixSeqpacket>

§

type WriteHalf<'a> = UnixWriteHalf<&'a UnixSeqpacket>