Skip to main content

QuicConfig

Struct QuicConfig 

Source
pub struct QuicConfig(/* private fields */);
Expand description

User-facing QUIC configuration backed by quinn.

Constructed with TLS credentials and passed to Config::with_quic. The runtime and UDP transport types are inferred from the server.

trillium_tokio::config()
    .with_quic(trillium_quinn::QuicConfig::from_single_cert(&cert_pem, &key_pem))
    .run(handler);

Implementations§

Source§

impl QuicConfig

Source

pub fn from_single_cert(cert_pem: &[u8], key_pem: &[u8]) -> Self

Build a QuicConfig from a single PEM-encoded certificate chain and private key.

Automatically configures ALPN for HTTP/3 (h3). For a custom TLS setup, use from_rustls_server_config.

Source

pub fn from_rustls_server_config(tls_config: ServerConfig) -> Self

Construct from a pre-built rustls::ServerConfig.

Use this when you need a custom TLS setup (client authentication, custom crypto provider, etc.). HTTP/3 ALPN (h3) is added automatically if not already present.

Source

pub fn from_quinn_server_config(config: ServerConfig) -> Self

Construct from a pre-built quinn::ServerConfig.

Use this when you also need to customize quinn transport parameters. The caller is responsible for configuring ALPN protocols (must include h3 to support HTTP/3). For custom TLS only, prefer from_rustls_server_config.

Source

pub fn from_cert_resolver(resolver: Arc<dyn ResolvesServerCert>) -> Self

Build a QuicConfig from a rustls::server::ResolvesServerCert cert resolver.

Use this to bring your own dynamic certificate source — for example, an ACME integration that rotates certificates over time. The resolver is consulted on every new connection, so renewals take effect immediately without rebuilding the QUIC server config.

If the resolver returns None for a given ClientHello (e.g. before the first certificate has been obtained), the TLS handshake fails and the connection is rejected. This makes it safe to bind the endpoint before any certificate is available.

Automatically configures ALPN for HTTP/3 (h3).

Trait Implementations§

Source§

impl<S> QuicConfig<S> for QuicConfig
where S: Server, S::Runtime: Unpin, S::UdpTransport: SocketTransport,

Source§

type Endpoint = QuinnEndpoint

The bound endpoint type produced by bind.
Source§

fn bind( self, addr: SocketAddr, runtime: S::Runtime, _info: &mut Info, ) -> Option<Result<Self::Endpoint>>

Bind a QUIC endpoint to the given address. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CompatExt for T

Source§

fn compat(self) -> Compat<T>

Applies the Compat adapter by value. Read more
Source§

fn compat_ref(&self) -> Compat<&T>

Applies the Compat adapter by shared reference. Read more
Source§

fn compat_mut(&mut self) -> Compat<&mut T>

Applies the Compat adapter by mutable reference. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more