Skip to main content

QuicConfig

Trait QuicConfig 

Source
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:

  1. User provides a QuicConfig via Config::with_quic
  2. During server startup, bind is called with the TCP listener’s address and runtime
  3. The resulting QuicEndpoint is stored on RunningConfig and drives the H3 accept loop

Required Associated Types§

Source

type Endpoint: QuicEndpoint

The bound endpoint type produced by bind.

Required Methods§

Source

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§

Source

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.

Source

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".

Implementations on Foreign Types§

Source§

impl<S: Server> QuicConfig<S> for ()

Source§

type Endpoint = ()

Source§

fn bind(self, _: SocketAddr, _: S::Runtime, _: &mut Info) -> Option<Result<()>>

Source§

fn is_configured(&self) -> bool

Implementors§