pub enum AnyTokioStream {
Tcp(TcpStream),
Unix(UnixStream),
}Expand description
A connected stream-type socket, either TCP or Unix-domain, adapted for use with tokio.
AnyTokioStreams are usually obtained from a call to AnyTokioListener::accept. This type implements AsyncRead and AsyncWrite, and is used to communicate with the connected peer in much the same way as a tokio::net::TcpStream.
§Availability
All platforms, but the Unix variant is only available on Unix-like platforms. Converting a Unix-domain socket on Windows will result in an error.
Requires the tokio feature.
Variants§
Tcp(TcpStream)
Unix(UnixStream)
A connected Unix-domain stream-type socket.
§Availability
Unix-like platforms only. Tokio currently does not support Unix-domain sockets on Windows.
Implementations§
Source§impl AnyTokioStream
impl AnyTokioStream
Sourcepub fn local_addr(&self) -> Result<SockAddr>
pub fn local_addr(&self) -> Result<SockAddr>
Returns the local address that this socket is bound to.
This method delegates to tokio::net::TcpStream::local_addr or tokio::net::UnixStream::local_addr, as appropriate.
Sourcepub fn peer_addr(&self) -> Result<SockAddr>
pub fn peer_addr(&self) -> Result<SockAddr>
Returns the remote address that this socket is connected to.
This method delegates to tokio::net::TcpStream::peer_addr or tokio::net::UnixStream::peer_addr, as appropriate.
Trait Implementations§
Source§impl AsFd for AnyTokioStream
Available on non-Windows only.
impl AsFd for AnyTokioStream
Source§fn as_fd(&self) -> BorrowedFd<'_>
fn as_fd(&self) -> BorrowedFd<'_>
Source§impl AsRawFd for AnyTokioStream
Available on non-Windows only.
impl AsRawFd for AnyTokioStream
Source§impl AsyncRead for AnyTokioStream
impl AsyncRead for AnyTokioStream
Source§impl AsyncWrite for AnyTokioStream
impl AsyncWrite for AnyTokioStream
Source§fn poll_write(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<Result<usize, Error>>
fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<Result<usize, Error>>
buf into the object. Read moreSource§fn poll_flush(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_flush( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_shutdown(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<(), Error>>
fn poll_shutdown( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<(), Error>>
Source§fn poll_write_vectored(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>],
) -> Poll<Result<usize, Error>>
fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[IoSlice<'_>], ) -> Poll<Result<usize, Error>>
poll_write, except that it writes from a slice of buffers. Read moreSource§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
poll_write_vectored
implementation. Read more