pub trait DatagramFactory:
Send
+ Sync
+ 'static {
// Required method
fn bind(&self, addr: SocketAddr) -> Result<Box<dyn DatagramSocket>>;
// Provided method
fn backend_name(&self) -> &'static str { ... }
}Expand description
Runtime-agnostic factory that binds a DatagramSocket on the calling
worker — the UDP sibling of AcceptorFactory. Injected into the serve path
so a QUIC/h3 listener obtains a prime- or tokio-backed UDP socket without
naming the concrete runtime. bind MUST be called from within a future
already running on the target runtime’s worker.
Required Methods§
fn bind(&self, addr: SocketAddr) -> Result<Box<dyn DatagramSocket>>
Provided Methods§
Sourcefn backend_name(&self) -> &'static str
fn backend_name(&self) -> &'static str
Name of the runtime backend this factory’s bind output must be
polled on ("prime", "tokio", …). The default "unknown" is
for factories that don’t declare one — test doubles and in-memory
fakes never need to, since they have no reactor affinity to
violate. Real backends override this so a caller-assembled
RuntimeSelection (every field is pub) can be checked for a
factory/runtime mismatch BEFORE the first poll, rather than
discovering it via an opaque failure deep inside the wrong
reactor (e.g. prime’s CURRENT_REACTOR is null when its
UdpSocket is driven from a tokio worker).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".