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
impl WebTransportConnection
Sourcepub async fn accept_bidi(&self) -> Option<InboundBidiStream>
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.
Sourcepub fn h3_connection(&self) -> &H3Connection
pub fn h3_connection(&self) -> &H3Connection
Returns the underlying HTTP/3 connection.
Sourcepub fn request_headers(&self) -> &Headers
pub fn request_headers(&self) -> &Headers
The headers from the CONNECT request that established this WebTransport session.
Sourcepub fn request_headers_mut(&mut self) -> &mut Headers
pub fn request_headers_mut(&mut self) -> &mut Headers
Mutably borrow the CONNECT request headers.
Sourcepub fn response_headers(&self) -> &Headers
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.
Sourcepub fn response_headers_mut(&mut self) -> &mut Headers
pub fn response_headers_mut(&mut self) -> &mut Headers
Mutably borrow the CONNECT response headers.
Sourcepub fn state(&self) -> &TypeSet
pub fn state(&self) -> &TypeSet
Borrow the TypeSet of state accumulated by the handler chain before the upgrade.
Sourcepub fn path(&self) -> Option<&str>
pub fn path(&self) -> Option<&str>
The :path of the CONNECT request that established this session, identifying which
WebTransport endpoint the peer asked for.
The :authority of the CONNECT request that established this session.
Sourcepub fn peer_addr(&self) -> SocketAddr
pub fn peer_addr(&self) -> SocketAddr
The peer’s socket address.
Sourcepub async fn accept_uni(&self) -> Option<InboundUniStream>
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.
Sourcepub async fn recv_datagram(&self) -> Option<Datagram>
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.
Sourcepub async fn accept_next_stream(&self) -> Option<InboundStream>
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.
Sourcepub fn send_datagram(&self, payload: &[u8]) -> Result<()>
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.
Sourcepub async fn open_bidi(&self) -> Result<OutboundBidiStream>
pub async fn open_bidi(&self) -> Result<OutboundBidiStream>
Open a new server-initiated bidirectional stream for this session.
Sourcepub async fn open_uni(&self) -> Result<OutboundUniStream>
pub async fn open_uni(&self) -> Result<OutboundUniStream>
Open a new server-initiated unidirectional stream for this session.