Struct wasi::sockets::udp::OutgoingDatagramStream

source ·
pub struct OutgoingDatagramStream { /* private fields */ }

Implementations§

source§

impl OutgoingDatagramStream

source

pub fn check_send(&self) -> Result<u64, ErrorCode>

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§

impl OutgoingDatagramStream

source

pub fn send(&self, datagrams: &[OutgoingDatagram]) -> Result<u64, ErrorCode>

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§

impl OutgoingDatagramStream

source

pub fn subscribe(&self) -> 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.

Trait Implementations§

source§

impl Debug for OutgoingDatagramStream

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.