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

Object Safety§

This trait is not object safe.

Implementors§

source§

impl NetworkStream for TcpStreamImpl

§

type ReaderRef<'a> = ReadHalf<'a> where Self: 'a

§

type WriterRef<'a> = WriteHalf<'a> where Self: 'a

§

type InnerStream = TcpStream

source§

impl NetworkStream for UdpStreamImpl

§

type ReaderRef<'a> = UdpStreamReadHalf<'static>

§

type WriterRef<'a> = UdpStreamWriteHalf<'a> where Self: 'a

§

type InnerStream = UdpStream