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 upgrade(&self) -> &Upgrade

Returns the HTTP CONNECT upgrade that initiated this WebTransport session.

Provides access to request headers, connection state, and peer information from the CONNECT request.

Source

pub fn upgrade_mut(&mut self) -> &mut Upgrade

Returns a mutable reference to the HTTP CONNECT upgrade that initiated this session.

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.