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§
Sourcefn receive(
&mut self,
self_: Resource<IncomingDatagramStream>,
max_results: u64,
) -> Result<Vec<IncomingDatagram>, SocketError>
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 returnserror(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
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html
- https://man7.org/linux/man-pages/man2/recv.2.html
- https://man7.org/linux/man-pages/man2/recvmmsg.2.html
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom
- https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)
- https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2
Sourcefn subscribe(
&mut self,
self_: Resource<IncomingDatagramStream>,
) -> Result<Resource<Pollable>>
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 0.2 only.
It’s planned to be removed when future
is natively supported in Preview3.
fn drop(&mut self, rep: Resource<IncomingDatagramStream>) -> Result<()>
Implementations on Foreign Types§
Source§impl<_T: HostIncomingDatagramStream + ?Sized + Send> HostIncomingDatagramStream for &mut _T
impl<_T: HostIncomingDatagramStream + ?Sized + Send> HostIncomingDatagramStream for &mut _T
Source§fn receive(
&mut self,
self_: Resource<IncomingDatagramStream>,
max_results: u64,
) -> Result<Vec<IncomingDatagram>, SocketError>
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 returnserror(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
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvfrom.html
- https://pubs.opengroup.org/onlinepubs/9699919799/functions/recvmsg.html
- https://man7.org/linux/man-pages/man2/recv.2.html
- https://man7.org/linux/man-pages/man2/recvmmsg.2.html
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv
- https://learn.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recvfrom
- https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ms741687(v=vs.85)
- https://man.freebsd.org/cgi/man.cgi?query=recv&sektion=2
Source§fn subscribe(
&mut self,
self_: Resource<IncomingDatagramStream>,
) -> Result<Resource<Pollable>>
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 0.2 only.
It’s planned to be removed when future
is natively supported in Preview3.