Skip to main content

SocketListener

Trait SocketListener 

Source
pub trait SocketListener:
    Sized
    + Send
    + Sync {
    type Stream: SocketStream + 'static;

    // Required methods
    fn bind<'life0, 'async_trait>(
        addr: &'life0 str,
    ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
       where Self: Sized + 'async_trait,
             'life0: 'async_trait;
    fn accept<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, SocketAddr)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

The TcpListener interface we need to mock

Required Associated Types§

Source

type Stream: SocketStream + 'static

The associated listener interface to be mocked too

Required Methods§

Source

fn bind<'life0, 'async_trait>( addr: &'life0 str, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: Sized + 'async_trait, 'life0: 'async_trait,

Creates a new SocketListener, which will be bound to the specified address.

Source

fn accept<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(Self::Stream, SocketAddr)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Accepts a new incoming connection from this listener.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§