Crates.io | wtransport |
lib.rs | wtransport |
version | 0.5.0 |
source | src |
created_at | 2023-05-25 19:45:52.658071 |
updated_at | 2024-11-08 07:43:02.049072 |
description | Implementation of the WebTransport (over HTTP3) protocol |
homepage | |
repository | https://github.com/BiagioFesta/wtransport |
max_upload_size | |
id | 874572 |
size | 296,254 |
WebTransport protocol, pure-rust, async-friendly.
WebTransport is a new protocol being developed to enable low-latency, bidirectional communication between clients and servers over the web. It aims to address the limitations of existing protocols like HTTP and WebSocket by offering a more efficient and flexible transport layer.
Please be aware that WebTransport is still a draft and not yet standardized. The WTransport library, while functional, is not considered completely production-ready. It should be used with caution and may undergo changes as the WebTransport specification evolves.
Server | Client |
---|---|
|
|
WebTransport is supported in modern browsers, enhancing the capabilities of web applications.
For instance, you can create a native browser WebTransport client connecting to a Rust server using the following JavaScript code:
// Create a WebTransport instance connecting to the Rust server
let transport = new WebTransport('https://[::1]:4433');
await transport.ready;
// Create a bidirectional stream
let stream = await transport.createBidirectionalStream();
// Send data from the client to the server
await stream.writable.getWriter().write(new TextEncoder().encode("hello"));
// Read data reply from the server
let data = await stream.readable.getReader().read();
console.log(data);
Check out the W3C WebTransport API documentation for more details and to explore the full capabilities of WebTransport in the browser.
git clone https://github.com/BiagioFesta/wtransport.git
cd wtransport/
Full
ExampleThe examples/full.rs
is a minimal but complete server example that demonstrates the usage of WebTransport.
You can run this example using Cargo, Rust's package manager, with the following command:
cargo run --example full
This example initiates an echo WebTransport server that can receive messages. It also includes an integrated HTTP server.
Open a supported web browser and navigate to the page http://127.0.0.1:8080.
WTransport has bindings for the following languages: