Trait cap_net_ext::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<()>;
}
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.

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.

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 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.

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 to [connect_into_tcp_stream], however instead of converting a TcpListener to a TcpStream, it leaves fd in the existing TcpListener.

source

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

Initiate a UDP connection.

This is simlar to 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.

Implementations on Foreign Types§

source§

impl PoolExt for Pool

Implementors§