Expand description
WebTransport wrapper for WebAssembly.
This crate wraps the WebTransport API and provides ergonomic Rust bindings. Some liberties have been taken to make the API more Rust-like and closer to native.
§Poll and async
The browser API is a set of promises, but the surface here is a state machine:
every operation is a poll_* method that a caller steps from its own loop, with
the async methods as thin wrappers over them. That is what implements
web_transport_trait::poll, so a sans-I/O caller needs no adapter, and it is
what makes an abandoned operation safe — the promise stays subscribed, so a chunk
or an accepted stream is never dropped on the floor between polls.
§Requirements
web-sys still gates the WebTransport bindings behind --cfg=web_sys_unstable_apis,
so this crate cannot compile without that flag. It cannot be enabled by a dependency;
it has to be set by the final build, for example via .cargo/config.toml:
[build]
rustflags = ["--cfg=web_sys_unstable_apis"]
rustdocflags = ["--cfg=web_sys_unstable_apis"]rustdocflags is separate because rustdoc does not inherit rustflags; without it
cargo doc and doctests fail even though cargo build succeeds.
Re-exports§
pub use web_transport_trait as generic;
Structs§
- Client
- Build a client with the given URL and options.
- Client
Builder - See
WebTransportOptions. - Recv
Stream - A stream of bytes received from the remote peer.
- Send
Stream - A stream of bytes sent to the remote peer.
- Session
- A session represents a connection between a client and a server.
Enums§
- Congestion
Control - The
WebTransportCongestionControlenum. - Error
- A WebTransport error classified based on the source.