pub trait HostIncomingDatagramStream {
    // Required methods
    fn receive(
        &mut self,
        self_: Resource<IncomingDatagramStream>,
        max_results: u64
    ) -> Result<Vec<IncomingDatagram>, SocketError>;
    fn subscribe(
        &mut self,
        self_: Resource<IncomingDatagramStream>
    ) -> Result<Resource<Pollable>>;
    fn drop(&mut self, rep: Resource<IncomingDatagramStream>) -> Result<()>;
}

Required Methods§

source

fn receive( &mut self, self_: Resource<IncomingDatagramStream>, max_results: u64 ) -> Result<Vec<IncomingDatagram>, SocketError>

Receive messages on the socket.

This function attempts to receive up to max-results datagrams on the socket without blocking. The returned list may contain fewer elements than requested, but never more.

This function returns successfully with an empty list when either:

  • max-results is 0, or:
  • max-results is greater than 0, but no results are immediately available. This function never returns error(would-block).
§Typical errors
  • remote-unreachable: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
  • connection-refused: The connection was refused. (ECONNREFUSED)
§References
source

fn subscribe( &mut self, self_: Resource<IncomingDatagramStream> ) -> Result<Resource<Pollable>>

Create a pollable which will resolve once the stream is ready to receive again.

Note: this function is here for WASI Preview2 only. It’s planned to be removed when future is natively supported in Preview3.

source

fn drop(&mut self, rep: Resource<IncomingDatagramStream>) -> Result<()>

Implementors§