Skip to main content

AsyncAcceptable

Trait AsyncAcceptable 

Source
pub trait AsyncAcceptable {
    type Stream: AsyncRead + AsyncWrite + Unpin + Send + 'static;

    // Required method
    fn poll_accept(&self, cx: &mut Context<'_>) -> Poll<Result<Self::Stream>>;

    // Provided method
    fn poll_accept_with_sockaddr(
        &self,
        cx: &mut Context<'_>,
    ) -> Poll<Result<(Self::Stream, SocketAddr)>> { ... }
}
Expand description

A Listener that can accept connections asynchronously.

Required Associated Types§

Source

type Stream: AsyncRead + AsyncWrite + Unpin + Send + 'static

The type of stream that will be returned by accept()

Required Methods§

Source

fn poll_accept(&self, cx: &mut Context<'_>) -> Poll<Result<Self::Stream>>

Poll accept a connection asynchronously.

Provided Methods§

Source

fn poll_accept_with_sockaddr( &self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::Stream, SocketAddr)>>

Poll accept a connection asynchronously, returning the stream and the peer address.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsyncAcceptable for TcpListener

Available on crate feature tokio-net only.
Source§

type Stream = TcpStream

Source§

fn poll_accept(&self, cx: &mut Context<'_>) -> Poll<Result<Self::Stream>>

Source§

fn poll_accept_with_sockaddr( &self, cx: &mut Context<'_>, ) -> Poll<Result<(Self::Stream, SocketAddr)>>

Source§

impl AsyncAcceptable for UnixListener

Available on Unix and crate feature tokio-net only.
Source§

type Stream = UnixStream

Source§

fn poll_accept(&self, cx: &mut Context<'_>) -> Poll<Result<Self::Stream>>

Implementors§

Source§

impl<R, W> AsyncAcceptable for ReusableListener<R, W>
where R: AsyncRead + Unpin + Send + 'static, W: AsyncWrite + Unpin + Send + 'static,