cap_net_ext

Trait PoolExt

Source
pub trait PoolExt: Sealed {
    // Required methods
    fn bind_existing_tcp_listener<A: ToSocketAddrs>(
        &self,
        listener: &TcpListener,
        addrs: A,
    ) -> Result<()>;
    fn bind_existing_udp_socket<A: ToSocketAddrs>(
        &self,
        socket: &UdpSocket,
        addrs: A,
    ) -> Result<()>;
    fn connect_into_tcp_stream<A: ToSocketAddrs>(
        &self,
        socket: TcpListener,
        addrs: A,
    ) -> Result<TcpStream>;
    fn connect_existing_tcp_listener<A: ToSocketAddrs>(
        &self,
        socket: &TcpListener,
        addrs: A,
    ) -> Result<()>;
    fn connect_existing_udp_socket<A: ToSocketAddrs>(
        &self,
        socket: &UdpSocket,
        addrs: A,
    ) -> Result<()>;
    fn tcp_binder<A: ToSocketAddrs>(&self, addrs: A) -> Result<TcpBinder>;
    fn udp_binder<A: ToSocketAddrs>(&self, addrs: A) -> Result<UdpBinder>;
    fn tcp_connecter<A: ToSocketAddrs>(&self, addrs: A) -> Result<TcpConnecter>;
    fn udp_connecter<A: ToSocketAddrs>(&self, addrs: A) -> Result<UdpConnecter>;
}
Expand description

A trait for extending Pool types.

These functions have a ToSocketAddrs argument, which can return either IPv4 or IPv6 addresses, however they also require the socket to be created with a specific address family up front. Consequently, it’s recommended to do address resolution outside of this API and just pass resolved SocketAddrs in.

Required Methods§

Source

fn bind_existing_tcp_listener<A: ToSocketAddrs>( &self, listener: &TcpListener, addrs: A, ) -> Result<()>

Bind a TcpListener to the specified address.

A newly-created TcpListener created with TcpListenerExt::new has not been bound yet; this function binds it. Before it can accept connections, it must be marked for listening with TcpListenerExt::listen.

This is similar to Pool::bind_tcp_listener in that it binds a TCP socket, however it does not create the socket itself, or perform the listen step.

This function ensures that the address to be bound is permitted by the pool, and performs the bind. To perform these steps separately, create a TcpBinder with Self::tcp_binder and use TcpBinder::bind_existing_tcp_listener.

Source

fn bind_existing_udp_socket<A: ToSocketAddrs>( &self, socket: &UdpSocket, addrs: A, ) -> Result<()>

Bind a UdpSocket to the specified address.

A newly-created UdpSocket created with UdpSocketExt::new has not been bound yet; this function binds it.

This is similar to Pool::bind_udp_socket in that it binds a UDP socket, however it does not create the socket itself.

This function ensures that the address to be bound is permitted by the pool, and performs the bind. To perform these steps separately, create a UdpBinder with Self::udp_binder and use UdpBinder::bind_existing_udp_socket.

Source

fn connect_into_tcp_stream<A: ToSocketAddrs>( &self, socket: TcpListener, addrs: A, ) -> Result<TcpStream>

Initiate a TCP connection, converting a TcpListener to a TcpStream.

This is simlar to Pool::connect_tcp_stream in that it performs a TCP connection, but instead of creating a new socket itself it takes a TcpListener, such as one created with TcpListenerExt::new.

Despite the name, this function uses the TcpListener type as a generic socket container.

This function ensures that the address to connect to is permitted by the pool, and performs the connect. To perform these steps separately, create a TcpConnecter with Self::tcp_connecter and use TcpConnecter::connect_into_tcp_stream.

Source

fn connect_existing_tcp_listener<A: ToSocketAddrs>( &self, socket: &TcpListener, addrs: A, ) -> Result<()>

Initiate a TCP connection on a socket.

This is simlar to Self::connect_into_tcp_stream, however instead of converting a TcpListener to a TcpStream, it leaves fd in the existing TcpListener.

This function ensures that the address to connect to is permitted by the pool, and performs the connect. To perform these steps separately, create a TcpConnecter with Self::tcp_connecter and use TcpConnecter::connect_existing_tcp_listener.

Source

fn connect_existing_udp_socket<A: ToSocketAddrs>( &self, socket: &UdpSocket, addrs: A, ) -> Result<()>

Initiate a UDP connection.

This is simlar to Pool::connect_udp_socket in that it performs a UDP connection, but instead of creating a new socket itself it takes a UdpSocket, such as one created with UdpSocketExt::new.

This function ensures that the address to connect to is permitted by the pool, and performs the connect. To perform these steps separately, create a UdpConnecter with Self::udp_connecter and use UdpConnecter::connect_existing_udp_socket.

Source

fn tcp_binder<A: ToSocketAddrs>(&self, addrs: A) -> Result<TcpBinder>

Create a TCP binder.

This is an alternative to Self::bind_existing_tcp_listener. It checks that all the addresses in addrs are permitted for TCP binding up front, and then records them in a TcpBinder which can then be used to make repeated TcpBinder::bind_existing_tcp_listener calls.

Source

fn udp_binder<A: ToSocketAddrs>(&self, addrs: A) -> Result<UdpBinder>

Create a UDP binder.

This is an alternative to Self::bind_existing_udp_socket. It checks that all the addresses in addrs are permitted for UDP binding up front, and then records them in a UdpBinder which can then be used to make repeated UdpBinder::bind_existing_udp_socket calls.

Source

fn tcp_connecter<A: ToSocketAddrs>(&self, addrs: A) -> Result<TcpConnecter>

Create a TCP connecter.

This is an alternative to Self::connect_into_tcp_stream and Self::connect_existing_tcp_listener. It checks that all the addresses in addrs are permitted for TCP connecting up front, and then records them in a TcpConnecter which can then be used to make repeated TcpConnecter::connect_into_tcp_stream and TcpConnecter::connect_existing_tcp_listener calls.

Source

fn udp_connecter<A: ToSocketAddrs>(&self, addrs: A) -> Result<UdpConnecter>

Create a UDP connecter.

This is an alternative to Self::connect_existing_udp_socket. It checks that all the addresses in addrs are permitted for UDP connecting up front, and then records them in a UdpConnecter which can then be used to make repeated UdpConnecter::connect_existing_udp_socket calls.

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 PoolExt for Pool

Implementors§