web-transport-quinn

Crates.ioweb-transport-quinn
lib.rsweb-transport-quinn
version
sourcesrc
created_at2024-04-06 05:33:00.66749
updated_at2024-12-03 23:08:50.230532
descriptionWebTransport library for Quinn
homepage
repositoryhttps://github.com/kixelated/web-transport-rs
max_upload_size
id1198077
Cargo.toml error:TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(kixelated)

documentation

README

crates.io docs.rs discord

web-transport-quinn

A wrapper around the Quinn API, abstracting away the annoying HTTP/3 internals. Provides a QUIC-like API but with web support!

WebTransport

WebTransport is a new web API that allows for low-level, bidirectional communication between a client and a server. It's available in the browser as an alternative to HTTP and WebSockets.

WebTransport is layered on top of HTTP/3 which itself is layered on top of QUIC. This library hides that detail and exposes only the QUIC API, delegating as much as possible to the underlying QUIC implementation (Quinn).

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.

Usage

To use web-transport-quinn, first you need to create a quinn::Endpoint; see the documentation and examples for more information. The only requirement is that the ALPN is set to web_transport_quinn::ALPN (aka h3).

Afterwards, you use web_transport_quinn::accept (as a server) or web_transport_quinn::connect (as a client) to establish a WebTransport session. This will take over the QUIC connection and perform the boring HTTP/3 handshake for you.

See the examples or moq-native for a full setup.

    // Create a QUIC client.
    let mut endpoint = quinn::Endpoint::client("[::]:0".parse()?)?;
    endpoint.set_default_client_config(/* ... */);

    // Connect to the given URL.
    let session = web_transport_quinn::connect(&client, &"https://localhost").await?;

    // Create a bidirectional stream.
    let (mut send, mut recv) = session.open_bi().await?;

    // Send a message.
    send.write(b"hello").await?;

API

The web-transport-quinn API is almost identical to the Quinn API, except that Connection is called Session.

When possible, Deref is used to expose the underlying Quinn API. However some of the API is wrapped or unavailable due to WebTransport limitations.

  • Stream IDs are not avaialble.
  • Error codes are not full VarInts (62-bits) and significantly smaller.
Commit count: 139

cargo fmt