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§
Sourcetype ReaderRef<'a>: AsyncReadExt + Send + Unpin
where
Self: 'a
type ReaderRef<'a>: AsyncReadExt + Send + Unpin where Self: 'a
The reader association type used to represent the read operation
Sourcetype WriterRef<'a>: AsyncWriteExt + Send + Unpin
where
Self: 'a
type WriterRef<'a>: AsyncWriteExt + Send + Unpin where Self: 'a
The writer association type used to represent the write operation
Sourcetype InnerStream: AsyncReadExt + AsyncWriteExt + Unpin + Send
type InnerStream: AsyncReadExt + AsyncWriteExt + Unpin + Send
Used to get internal specific implementations such as UdpStream
Required Methods§
Sourcefn split(&mut self) -> (Self::ReaderRef<'_>, Self::WriterRef<'_>)
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.
Sourcefn into_inner_stream(self) -> Self::InnerStream
fn into_inner_stream(self) -> Self::InnerStream
Get the internal concrete implementation, note that this operation transfers ownership
Sourcefn local_addr(&self) -> Result<SocketAddr, Error>
fn local_addr(&self) -> Result<SocketAddr, Error>
get local address
Sourcefn peer_addr(&self) -> Result<SocketAddr, Error>
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.