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

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

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

Associated Types

type Remote: Remote[src]

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

Loading content...

Required methods

fn listen(addr: SocketAddr) -> Result<ListeningInfo<Self>>[src]

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

fn accept(&self, accept_remote: &dyn Fn(AcceptedType<'_, Self::Remote>))[src]

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.

Loading content...

Provided methods

fn send_to(&self, _addr: SocketAddr, _data: &[u8]) -> SendStatus[src]

Sends a raw data from a resource. Similar to Remote::send() but the resource that sends the data is a Local. The implementator must only implement this function if the local resource can also send data. This behaviour usually happens when the transport to implement is not connection oriented.

Loading content...

Implementors

Loading content...