Skip to main content

QuicEndpoint

Trait QuicEndpoint 

Source
pub trait QuicEndpoint:
    Send
    + Sync
    + 'static {
    type Connection: QuicConnectionTrait;

    // Required methods
    fn accept(&self) -> impl Future<Output = Option<Self::Connection>> + Send;
    fn connect(
        &self,
        addr: SocketAddr,
        server_name: &str,
    ) -> impl Future<Output = Result<Self::Connection>> + Send;

    // Provided method
    fn local_addr(&self) -> Result<SocketAddr> { ... }
}
Expand description

A bound QUIC endpoint that accepts and initiates connections.

Analogous to Server for TCP. QUIC library adapters implement this to provide the connection accept loop (server) and outbound connections (client).

The () implementation is a no-op (HTTP/3 disabled). Server-only implementations may return an error from connect; client-only implementations may return None from accept.

Required Associated Types§

Source

type Connection: QuicConnectionTrait

The connection type yielded by this endpoint.

Required Methods§

Source

fn accept(&self) -> impl Future<Output = Option<Self::Connection>> + Send

Accept the next inbound QUIC connection, or return None if the endpoint is done.

Source

fn connect( &self, addr: SocketAddr, server_name: &str, ) -> impl Future<Output = Result<Self::Connection>> + Send

Initiate a QUIC connection to the given address.

server_name is the SNI hostname used for TLS verification.

Provided Methods§

Source

fn local_addr(&self) -> Result<SocketAddr>

The local address this endpoint is bound to. The default impl returns Unsupported; adapters override when a bound UDP socket is available.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl QuicEndpoint for ()

Source§

type Connection = NoQuic

Source§

async fn accept(&self) -> Option<NoQuic>

Source§

async fn connect(&self, _: SocketAddr, _: &str) -> Result<NoQuic>

Implementors§