Skip to main content

WebTransportConnection

Struct WebTransportConnection 

Source
pub struct WebTransportConnection { /* private fields */ }
Expand description

A handle to an active WebTransport session.

Passed to your WebTransportHandler when a client opens a WebTransport session. Use it to accept streams from the client, open server-initiated streams, and exchange datagrams.

Implementations§

Source§

impl WebTransportConnection

Source

pub async fn accept_bidi(&self) -> Option<InboundBidiStream>

Accept the next inbound bidirectional stream for this session.

Returns None when the session is shutting down or the QUIC connection has closed.

Source

pub fn runtime(&self) -> &Runtime

Returns the async runtime for this server.

Source

pub fn h3_connection(&self) -> &H3Connection

Returns the underlying HTTP/3 connection.

Source

pub fn request_headers(&self) -> &Headers

The headers from the CONNECT request that established this WebTransport session.

Source

pub fn request_headers_mut(&mut self) -> &mut Headers

Mutably borrow the CONNECT request headers.

Source

pub fn response_headers(&self) -> &Headers

The headers from the CONNECT response that established this WebTransport session.

On the client side, these are the headers the server sent alongside its 200 response to the extended CONNECT (e.g. server identification, custom extension hints, CDN-injected headers, Set-Cookie). On the server side this is empty — by the time the handler runs, the response has already been sent.

Source

pub fn response_headers_mut(&mut self) -> &mut Headers

Mutably borrow the CONNECT response headers.

Source

pub fn state(&self) -> &TypeSet

Borrow the TypeSet of state accumulated by the handler chain before the upgrade.

Source

pub fn state_mut(&mut self) -> &mut TypeSet

Mutably borrow the TypeSet of state.

Source

pub fn path(&self) -> Option<&str>

The :path of the CONNECT request that established this session, identifying which WebTransport endpoint the peer asked for.

Source

pub fn authority(&self) -> Option<&str>

The :authority of the CONNECT request that established this session.

Source

pub fn peer_addr(&self) -> SocketAddr

The peer’s socket address.

Source

pub async fn accept_uni(&self) -> Option<InboundUniStream>

Accept the next inbound unidirectional stream for this session.

Returns None when the session is shutting down or the QUIC connection has closed.

Source

pub async fn recv_datagram(&self) -> Option<Datagram>

Receive the next datagram for this session.

Returns None when the session is shutting down or the QUIC connection has closed.

Source

pub async fn accept_next_stream(&self) -> Option<InboundStream>

Accept the next inbound stream for this session.

Races the bidi and uni stream channels and returns whichever arrives first. Returns None when the session ends.

Datagrams are intentionally excluded — use recv_datagram in a separate concurrent loop, as datagrams typically require lower latency than stream acceptance.

Source

pub fn send_datagram(&self, payload: &[u8]) -> Result<()>

Send an unreliable datagram to the client.

Returns an error if the QUIC connection does not support datagrams or the payload is too large.

Source

pub async fn open_bidi(&self) -> Result<OutboundBidiStream>

Open a new server-initiated bidirectional stream for this session.

Source

pub async fn open_uni(&self) -> Result<OutboundUniStream>

Open a new server-initiated unidirectional stream for this session.

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.