pub trait HostOutgoingDatagramStream {
    // Required methods
    fn check_send(
        &mut self,
        self_: Resource<OutgoingDatagramStream>,
    ) -> Result<u64, SocketError>;
    fn send<'life0, 'async_trait>(
        &'life0 mut self,
        self_: Resource<OutgoingDatagramStream>,
        datagrams: Vec<OutgoingDatagram>,
    ) -> Pin<Box<dyn Future<Output = Result<u64, SocketError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe(
        &mut self,
        self_: Resource<OutgoingDatagramStream>,
    ) -> Result<Resource<Pollable>>;
    fn drop(&mut self, rep: Resource<OutgoingDatagramStream>) -> Result<()>;
}

Required Methods§

source

fn check_send( &mut self, self_: Resource<OutgoingDatagramStream>, ) -> Result<u64, SocketError>

Check readiness for sending. This function never blocks.

Returns the number of datagrams permitted for the next call to send, or an error. Calling send with more datagrams than this function has permitted will trap.

When this function returns ok(0), the subscribe pollable will become ready when this function will report at least ok(1), or an error.

Never returns would-block.

source

fn send<'life0, 'async_trait>( &'life0 mut self, self_: Resource<OutgoingDatagramStream>, datagrams: Vec<OutgoingDatagram>, ) -> Pin<Box<dyn Future<Output = Result<u64, SocketError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send messages on the socket.

This function attempts to send all provided datagrams on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never returns error(would-block). If none of the datagrams were able to be sent, ok(0) is returned.

This function semantically behaves the same as iterating the datagrams list and sequentially sending each individual datagram until either the end of the list has been reached or the first error occurred. If at least one datagram has been sent successfully, this function never returns an error.

If the input list is empty, the function returns ok(0).

Each call to send must be permitted by a preceding check-send. Implementations must trap if either check-send was not called or datagrams contains more items than check-send permitted.

§Typical errors
  • invalid-argument: The remote-address has the wrong address family. (EAFNOSUPPORT)
  • invalid-argument: The IP address in remote-address is set to INADDR_ANY (0.0.0.0 / ::). (EDESTADDRREQ, EADDRNOTAVAIL)
  • invalid-argument: The port in remote-address is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL)
  • invalid-argument: The socket is in “connected” mode and remote-address is some value that does not match the address passed to stream. (EISCONN)
  • invalid-argument: The socket is not “connected” and no value for remote-address was provided. (EDESTADDRREQ)
  • remote-unreachable: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
  • connection-refused: The connection was refused. (ECONNREFUSED)
  • datagram-too-large: The datagram is too large. (EMSGSIZE)
§References
source

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

Create a pollable which will resolve once the stream is ready to send 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<OutgoingDatagramStream>) -> Result<()>

Implementations on Foreign Types§

source§

impl<_T: HostOutgoingDatagramStream + ?Sized + Send> HostOutgoingDatagramStream for &mut _T

source§

fn check_send( &mut self, self_: Resource<OutgoingDatagramStream>, ) -> Result<u64, SocketError>

Check readiness for sending. This function never blocks.

Returns the number of datagrams permitted for the next call to send, or an error. Calling send with more datagrams than this function has permitted will trap.

When this function returns ok(0), the subscribe pollable will become ready when this function will report at least ok(1), or an error.

Never returns would-block.

source§

fn send<'life0, 'async_trait>( &'life0 mut self, self_: Resource<OutgoingDatagramStream>, datagrams: Vec<OutgoingDatagram>, ) -> Pin<Box<dyn Future<Output = Result<u64, SocketError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send messages on the socket.

This function attempts to send all provided datagrams on the socket without blocking and returns how many messages were actually sent (or queued for sending). This function never returns error(would-block). If none of the datagrams were able to be sent, ok(0) is returned.

This function semantically behaves the same as iterating the datagrams list and sequentially sending each individual datagram until either the end of the list has been reached or the first error occurred. If at least one datagram has been sent successfully, this function never returns an error.

If the input list is empty, the function returns ok(0).

Each call to send must be permitted by a preceding check-send. Implementations must trap if either check-send was not called or datagrams contains more items than check-send permitted.

§Typical errors
  • invalid-argument: The remote-address has the wrong address family. (EAFNOSUPPORT)
  • invalid-argument: The IP address in remote-address is set to INADDR_ANY (0.0.0.0 / ::). (EDESTADDRREQ, EADDRNOTAVAIL)
  • invalid-argument: The port in remote-address is set to 0. (EDESTADDRREQ, EADDRNOTAVAIL)
  • invalid-argument: The socket is in “connected” mode and remote-address is some value that does not match the address passed to stream. (EISCONN)
  • invalid-argument: The socket is not “connected” and no value for remote-address was provided. (EDESTADDRREQ)
  • remote-unreachable: The remote address is not reachable. (ECONNRESET, ENETRESET on Windows, EHOSTUNREACH, EHOSTDOWN, ENETUNREACH, ENETDOWN, ENONET)
  • connection-refused: The connection was refused. (ECONNREFUSED)
  • datagram-too-large: The datagram is too large. (EMSGSIZE)
§References
source§

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

Create a pollable which will resolve once the stream is ready to send 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<OutgoingDatagramStream>) -> Result<()>

Implementors§