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 methods
fn connect_with_alpn(
&self,
addr: SocketAddr,
server_name: &str,
alpn: &[Cow<'static, [u8]>],
) -> impl Future<Output = Result<Self::Connection>> + Send { ... }
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§
Sourcetype Connection: QuicConnectionTrait
type Connection: QuicConnectionTrait
The connection type yielded by this endpoint.
Required Methods§
Sourcefn accept(&self) -> impl Future<Output = Option<Self::Connection>> + Send
fn accept(&self) -> impl Future<Output = Option<Self::Connection>> + Send
Accept the next inbound QUIC connection, or return None if the endpoint is done.
Sourcefn connect(
&self,
addr: SocketAddr,
server_name: &str,
) -> impl Future<Output = Result<Self::Connection>> + Send
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§
Sourcefn connect_with_alpn(
&self,
addr: SocketAddr,
server_name: &str,
alpn: &[Cow<'static, [u8]>],
) -> impl Future<Output = Result<Self::Connection>> + Send
fn connect_with_alpn( &self, addr: SocketAddr, server_name: &str, alpn: &[Cow<'static, [u8]>], ) -> impl Future<Output = Result<Self::Connection>> + Send
Initiate a QUIC connection advertising alpn for this connection only, overriding the
endpoint’s configured default ALPN. An empty list uses the default.
Lets one bound endpoint negotiate different application protocols per connection (e.g. h3
for HTTP/3 origins and doq for a DNS-over-QUIC resolver) over the same UDP socket. The
default implementation ignores alpn and calls connect; adapters
that can vary ALPN per connection override it.
Sourcefn local_addr(&self) -> Result<SocketAddr>
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".