Expand description
WebTransport is a protocol for client-server communication over QUIC. It’s available in the browser as an alternative to HTTP and WebSockets.
WebTransport is layered on top of HTTP/3 which is then layered on top of QUIC. This library hides that detail and tries to expose only the QUIC API, delegating as much as possible to the underlying implementation. See the Quinn documentation for more documentation.
QUIC provides two primary APIs:
§Streams
QUIC streams are ordered, reliable, flow-controlled, and optionally bidirectional. Both endpoints can create and close streams (including an error code) with no overhead. You can think of them as TCP connections, but shared over a single QUIC connection.
§Datagrams
QUIC datagrams are unordered, unreliable, and not flow-controlled. Both endpoints can send datagrams below the MTU size (~1.2kb minimum) and they might arrive out of order or not at all. They are basically UDP packets, except they are encrypted and congestion controlled.
§Limitations
WebTransport is able to be pooled with HTTP/3 and multiple WebTransport sessions.
This crate avoids that complexity, doing the bare minimum to support a single WebTransport session that owns the entire QUIC connection.
If you want to support HTTP/3 on the same host/port, you should use another crate (ex. h3-webtransport
).
If you want to support multiple WebTransport sessions over the same QUIC connection… you should just dial a new QUIC connection instead.
Re-exports§
pub use quinn;
Structs§
- Client
- A client for connecting to a WebTransport server.
- Client
Builder - Construct a WebTransport Client using sane defaults.
- Closed
Stream - An error indicating the stream was already closed.
- NoCertificate
Verification - Recv
Stream - A stream that can be used to recieve bytes. See
quinn::RecvStream
. - Request
- A mostly complete WebTransport handshake, just awaiting the server’s decision on whether to accept or reject the session based on the URL.
- Send
Stream - A stream that can be used to send bytes. See
quinn::SendStream
. - Server
- A WebTransport server that accepts new sessions.
- Server
Builder - Construct a WebTransport Server using sane defaults.
- Session
- An established WebTransport session, acting like a full QUIC connection. See
quinn::Connection
. - Session
Accept
Enums§
- Client
Error - An error returned when connecting to a WebTransport endpoint.
- Congestion
Control - Allows specifying a class of congestion control algorithm.
- Read
Error - An error when reading from
crate::RecvStream
. Similar toquinn::ReadError
. - Read
Exact Error - An error returned by
crate::RecvStream::read_exact
. Similar toquinn::ReadExactError
. - Read
ToEnd Error - An error returned by
crate::RecvStream::read_to_end
. Similar toquinn::ReadToEndError
. - Server
Error - An error returned when receiving a new WebTransport session.
- Session
Error - An errors returned by
crate::Session
, split based on if they are underlying QUIC errors or WebTransport errors. - Stopped
Error - An error returned by
crate::SendStream::stopped
. Similar toquinn::StoppedError
. - WebTransport
Error - An error that can occur when reading/writing the WebTransport stream header.
- Write
Error - An error when writing to
crate::SendStream
. Similar toquinn::WriteError
.
Constants§
- ALPN
- The HTTP/3 ALPN is required when negotiating a QUIC connection.