Trait NativeDatagramChannel
pub trait NativeDatagramChannel:
Send
+ Sync
+ 'static {
// Required methods
fn max_payload_size(&self) -> Option<usize>;
fn send(
&self,
payload: Bytes,
policy: NativeSendPolicy,
) -> Result<(), NativeSendError>;
fn send_ready(&self) -> NativeSendReady ⓘ;
fn poll_recv(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<Option<Bytes>, NativeRecvError>>;
fn dropped(&self) -> u64;
// Provided method
fn release_recv(&self) { ... }
}http and std only.Expand description
Unreliable delivery of HTTP Datagrams associated with one request, such as HTTP/3 QUIC DATAGRAM frames (RFC 9297 §2.1).
A transport publishes its implementation as a NativeDatagrams extension on the
upgraded I/O. Receiving is demultiplexed by the transport; one association has at most
one consumer. Enqueueing a datagram never implies delivery.
Required Methods§
fn max_payload_size(&self) -> Option<usize>
fn max_payload_size(&self) -> Option<usize>
The largest payload that can currently be sent, or None while native datagrams are
not negotiated. A snapshot: send decides.
fn send(
&self,
payload: Bytes,
policy: NativeSendPolicy,
) -> Result<(), NativeSendError>
fn send( &self, payload: Bytes, policy: NativeSendPolicy, ) -> Result<(), NativeSendError>
Hand a datagram to the transport without waiting.
Eligibility follows the transport’s send state of the request stream, whoever holds
the channel: once it is closed this returns NativeSendError::Closed.
fn send_ready(&self) -> NativeSendReady ⓘ
fn send_ready(&self) -> NativeSendReady ⓘ
A wait for room to send under NativeSendPolicy::RejectWhenFull, registered on
creation.
Create it before a send that may return NativeSendError::Full and await it after
the refusal, so a wake in between is not missed. It also completes once the send side
closes. Every call is an independent registration and dropping it is harmless. A wake
is a hint: retry the send. Transports that never refuse return NativeSendReady::now.
Provided Methods§
fn release_recv(&self)
fn release_recv(&self)
The consumer is gone: discard queued datagrams and drop (count) later ones. The request stream itself is unaffected.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".