netemul

Trait RealmTcpListener

Source
pub trait RealmTcpListener: Sized {
    // Required method
    fn listen_in_realm_with<'a>(
        realm: &'a TestRealm<'a>,
        addr: SocketAddr,
        setup: impl FnOnce(&Socket) -> Result<(), Error> + 'a,
    ) -> LocalBoxFuture<'a, Result<Self, Error>>;

    // Provided method
    fn listen_in_realm<'a>(
        realm: &'a TestRealm<'a>,
        addr: SocketAddr,
    ) -> LocalBoxFuture<'a, Result<Self, Error>> { ... }
}
Expand description

Trait describing TCP listeners bound in a testing realm.

Required Methods§

Source

fn listen_in_realm_with<'a>( realm: &'a TestRealm<'a>, addr: SocketAddr, setup: impl FnOnce(&Socket) -> Result<(), Error> + 'a, ) -> LocalBoxFuture<'a, Result<Self, Error>>

Creates a TCP listener by creating a Socket2 socket in realm. Closure setup is called with the reference of the socket before the socket is bound to addr.

Provided Methods§

Source

fn listen_in_realm<'a>( realm: &'a TestRealm<'a>, addr: SocketAddr, ) -> LocalBoxFuture<'a, Result<Self, Error>>

Creates a TCP listener in realm bound to addr.

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.

Implementations on Foreign Types§

Source§

impl RealmTcpListener for TcpListener

Source§

fn listen_in_realm_with<'a>( realm: &'a TestRealm<'a>, addr: SocketAddr, setup: impl FnOnce(&Socket) -> Result<(), Error> + 'a, ) -> LocalBoxFuture<'a, Result<Self, Error>>

Source§

impl RealmTcpListener for TcpListener

Source§

fn listen_in_realm_with<'a>( realm: &'a TestRealm<'a>, addr: SocketAddr, setup: impl FnOnce(&Socket) -> Result<(), Error> + 'a, ) -> LocalBoxFuture<'a, Result<Self, Error>>

Implementors§