Trait message_io::network::adapter::Local[][src]

pub trait Local: Resource + Sized {
    type Remote: Remote;
    fn listen(addr: SocketAddr) -> Result<ListeningInfo<Self>>;
fn accept(&self, accept_remote: impl FnMut(AcceptedType<'_, Self::Remote>)); fn send_to(&self, _addr: SocketAddr, _data: &[u8]) -> SendStatus { ... } }
Expand description

The resource used to represent a local listener. It usually is a wrapper over a socket/listener.

Associated Types

The type of the Remote accepted by the Self::accept() function. It must be the same as the adapter’s Remote.

Required methods

Called when the user performs a listening request from an specific address. The implementator is in change of creating the corresponding local resource. It also must returned the listening address since it could not be the same as param addr (e.g. listening from port 0).

Called when a local resource received an event. It means that some resource have tried to connect. The implementator is in charge of accepting this connection. The accept_remote must be called for each accept request in the local resource. Note that an accept event could imply to process more than one remote. This function is called when the local resource has one or more pending connections. The implementator must process all these pending connections in this call. For most of the cases it means accept connections until the network resource returns WouldBlock.

Provided methods

Sends a raw data from a resource. Similar to Remote::send() but the resource that sends the data is a Local. This behaviour usually happens when the transport to implement is not connection oriented.

The implementator must only implement this function if the local resource can also send data.

Implementors