Skip to main content

H3Connection

Struct H3Connection 

Source
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

Source

pub fn new(context: Arc<HttpContext>) -> Arc<Self>

Construct a new H3Connection to manage HTTP/3 for a given peer.

Source

pub fn swansong(&self) -> &Swansong

Retrieve the Swansong shutdown handle for this HTTP/3 connection. See also H3Connection::shut_down

Source

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

Source

pub fn context(&self) -> Arc<HttpContext>

Retrieve the HttpContext for this server.

Source

pub fn peer_settings(&self) -> Option<&H3Settings>

Returns the peer’s HTTP/3 settings, available once the peer’s control stream has been processed.

Source

pub async fn process_inbound_bidi<Transport, Handler, Fut>( self: Arc<Self>, transport: Transport, handler: Handler, stream_id: u64, ) -> Result<H3StreamResult<Transport>, H3Error>
where Transport: AsyncRead + AsyncWrite + Unpin + Send + Sync + 'static, Handler: FnOnce(Conn<Transport>) -> Fut, Fut: Future<Output = Conn<Transport>>,

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.

Source

pub async fn run_outbound_control<T>(&self, stream: T) -> Result<(), H3Error>
where T: AsyncWrite + Unpin + Send,

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.

Source

pub async fn run_encoder<T>(&self, stream: T) -> Result<(), H3Error>
where T: AsyncWrite + Unpin + Send,

Run the outbound QPACK encoder stream for the duration of the connection.

Writes the stream type byte, then drains encoder-stream instructions from the encoder dynamic table as they are enqueued. Returns when the connection shuts down or the table is marked failed.

§Errors

Returns an H3Error in case of io error.

Source

pub async fn run_decoder<T>(&self, stream: T) -> Result<(), H3Error>
where T: AsyncWrite + Unpin + Send,

Run the outbound QPACK decoder stream for the duration of the connection.

Writes the stream type byte, then loops sending Section Acknowledgement and Insert Count Increment instructions as they become needed. Returns when the connection shuts down.

§Errors

Returns an H3Error in case of io error or http/3 semantic error.

Source

pub async fn process_inbound_uni<T>( &self, stream: T, ) -> Result<UniStreamResult<T>, H3Error>
where T: AsyncRead + Unpin + Send,

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.

Trait Implementations§

Source§

impl Debug for H3Connection

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.