pub trait QuicConfig<S: Server>: Send + 'static {
type Endpoint: QuicEndpoint;
// Required method
fn bind(
self,
addr: SocketAddr,
runtime: S::Runtime,
info: &mut Info,
) -> Option<Result<Self::Endpoint>>;
// Provided methods
fn is_configured(&self) -> bool { ... }
fn bind_with_socket(
self,
socket: UdpSocket,
runtime: S::Runtime,
info: &mut Info,
) -> Result<Self::Endpoint>
where Self: Sized { ... }
}Expand description
Configuration for a QUIC endpoint, provided by the user at server setup time.
QUIC library adapters implement this (e.g. trillium_quinn::QuicConfig). The ()
implementation produces no binding (HTTP/3 disabled).
The generic flow is:
- User provides a
QuicConfigviaConfig::with_quic - During server startup,
bindis called with the TCP listener’s address and runtime - The resulting
QuicEndpointis stored onRunningConfigand drives the H3 accept loop
Required Associated Types§
Sourcetype Endpoint: QuicEndpoint
type Endpoint: QuicEndpoint
The bound endpoint type produced by bind.
Required Methods§
Sourcefn bind(
self,
addr: SocketAddr,
runtime: S::Runtime,
info: &mut Info,
) -> Option<Result<Self::Endpoint>>
fn bind( self, addr: SocketAddr, runtime: S::Runtime, info: &mut Info, ) -> Option<Result<Self::Endpoint>>
Bind a QUIC endpoint to the given address.
The runtime is provided so that QUIC library adapters can bridge to the active async runtime for timers, spawning, and UDP I/O.
Returns None if QUIC is not configured (the () case), Some(Ok(binding)) on success,
or Some(Err(..)) if binding fails.
Provided Methods§
Sourcefn is_configured(&self) -> bool
fn is_configured(&self) -> bool
Whether this is a real QUIC configuration (true) rather than the no-op () (false).
Lets a caller decide whether to set up a QUIC listener at all without consuming self by
calling bind. The default returns true; only the () implementation
overrides it.
Sourcefn bind_with_socket(
self,
socket: UdpSocket,
runtime: S::Runtime,
info: &mut Info,
) -> Result<Self::Endpoint>where
Self: Sized,
fn bind_with_socket(
self,
socket: UdpSocket,
runtime: S::Runtime,
info: &mut Info,
) -> Result<Self::Endpoint>where
Self: Sized,
Bind a QUIC endpoint over a pre-claimed std::net::UdpSocket.
The multi-listener server builder claims the UDP socket eagerly (fail-fast at
bind_quic time) and hands it through to the adapter when the runtime is available.
The default implementation reads the socket’s local address and delegates to
bind, which is correct but rebinds the address; adapters should override
to consume the pre-claimed socket directly (e.g. quinn accepts a std::net::UdpSocket
in Endpoint::new).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".