pub struct H3Connection { /* private fields */ }Expand description
Shared state for a single HTTP/3 QUIC connection.
Call the appropriate methods on this type for each stream accepted from the QUIC connection.
Implementations§
Source§impl H3Connection
impl H3Connection
Sourcepub fn new(context: Arc<HttpContext>) -> Arc<Self>
pub fn new(context: Arc<HttpContext>) -> Arc<Self>
Construct a new H3Connection to manage HTTP/3 for a given peer.
Sourcepub fn swansong(&self) -> &Swansong
pub fn swansong(&self) -> &Swansong
Retrieve the Swansong shutdown handle for this HTTP/3 connection. See also
H3Connection::shut_down
Sourcepub fn shut_down(&self) -> ShutdownCompletion
pub fn shut_down(&self) -> ShutdownCompletion
Attempt graceful shutdown of this HTTP/3 connection (all streams).
The returned ShutdownCompletion type can
either be awaited in an async context or blocked on with ShutdownCompletion::block in a
blocking context
Note that this will NOT shut down the server. To shut down the whole server, use
HttpContext::shut_down
Sourcepub fn context(&self) -> Arc<HttpContext>
pub fn context(&self) -> Arc<HttpContext>
Retrieve the HttpContext for this server.
Sourcepub fn peer_settings(&self) -> Option<&H3Settings>
pub fn peer_settings(&self) -> Option<&H3Settings>
Returns the peer’s HTTP/3 settings, available once the peer’s control stream has been processed.
Sourcepub async fn process_inbound_bidi<Transport, Handler, Fut>(
self: Arc<Self>,
transport: Transport,
handler: Handler,
stream_id: u64,
) -> Result<H3StreamResult<Transport>, H3Error>
pub async fn process_inbound_bidi<Transport, Handler, Fut>( self: Arc<Self>, transport: Transport, handler: Handler, stream_id: u64, ) -> Result<H3StreamResult<Transport>, H3Error>
Process a single HTTP/3 request-response cycle on a bidirectional stream.
Call this once per accepted bidirectional stream. Returns
H3StreamResult::WebTransport if the stream opens a WebTransport session rather than
a standard HTTP/3 request.
§Errors
Returns an H3Error in case of io error or http/3 semantic error.
Sourcepub async fn run_outbound_control<T>(&self, stream: T) -> Result<(), H3Error>
pub async fn run_outbound_control<T>(&self, stream: T) -> Result<(), H3Error>
Run this server’s HTTP/3 outbound control stream.
Sends the initial SETTINGS frame, then sends GOAWAY when the connection shuts down. Returns after GOAWAY is sent; keep the stream open until the QUIC connection closes (closing a control stream is a connection error per RFC 9114 §6.2.1).
§Errors
Returns an H3Error in case of io error or http/3 semantic error.
Sourcepub async fn run_encoder<T>(&self, stream: T) -> Result<(), H3Error>
pub async fn run_encoder<T>(&self, stream: T) -> Result<(), H3Error>
Initialize and hold open the outbound QPACK encoder stream for the duration of the connection.
§Errors
Returns an H3Error in case of io error or http/3 semantic error.
Sourcepub async fn run_decoder<T>(&self, stream: T) -> Result<(), H3Error>
pub async fn run_decoder<T>(&self, stream: T) -> Result<(), H3Error>
Initialize and hold open the outbound QPACK decoder stream for the duration of the connection.
§Errors
Returns an H3Error in case of io error or http/3 semantic error.
Sourcepub async fn process_inbound_uni<T>(
&self,
stream: T,
) -> Result<UniStreamResult<T>, H3Error>
pub async fn process_inbound_uni<T>( &self, stream: T, ) -> Result<UniStreamResult<T>, H3Error>
Handle an inbound unidirectional HTTP/3 stream from the peer.
Internal stream types (control, QPACK encoder/decoder) are handled automatically;
application streams are returned via UniStreamResult for the caller to process.
§Errors
Returns a H3Error in case of io error or http/3 semantic error.