Trait NetworkStream

Source
pub trait NetworkStream:
    AsyncReadExt
    + AsyncWriteExt
    + Send
    + Unpin
    + 'static {
    type ReaderRef<'a>: AsyncReadExt + Send + Unpin
       where Self: 'a;
    type WriterRef<'a>: AsyncWriteExt + Send + Unpin
       where Self: 'a;
    type InnerStream: AsyncReadExt + AsyncWriteExt + Unpin + Send;

    // Required methods
    fn split(&mut self) -> (Self::ReaderRef<'_>, Self::WriterRef<'_>);
    fn into_inner_stream(self) -> Self::InnerStream;
    fn local_addr(&self) -> Result<SocketAddr, Error>;
    fn peer_addr(&self) -> Result<SocketAddr, Error>;
}
Expand description

Used to abstract Stream operations, see tokio::net::TcpStream for details

Required Associated Types§

Source

type ReaderRef<'a>: AsyncReadExt + Send + Unpin where Self: 'a

The reader association type used to represent the read operation

Source

type WriterRef<'a>: AsyncWriteExt + Send + Unpin where Self: 'a

The writer association type used to represent the write operation

Source

type InnerStream: AsyncReadExt + AsyncWriteExt + Unpin + Send

Used to get internal specific implementations such as UdpStream

Required Methods§

Source

fn split(&mut self) -> (Self::ReaderRef<'_>, Self::WriterRef<'_>)

Splitting the Stream into a read side and a write side is useful in scenarios where you need to use read and write separately.

Source

fn into_inner_stream(self) -> Self::InnerStream

Get the internal concrete implementation, note that this operation transfers ownership

Source

fn local_addr(&self) -> Result<SocketAddr, Error>

get local address

Source

fn peer_addr(&self) -> Result<SocketAddr, Error>

get peer address

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.

Implementors§