WTransport
WebTransport protocol, pure-rust, async-friendly.
Introduction
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.
Benefits of WebTransport
- 🚀 Low latency: WebTransport is designed to minimize latency, making it suitable for real-time applications such as gaming, video streaming, and collaborative editing.
- 🔄 Bidirectional communication: WebTransport allows simultaneous data exchange between the client and server, enabling efficient back-and-forth communication without the need for multiple requests.
- 🔀 Multiplexing: With WebTransport, multiple streams can be multiplexed over a single connection, reducing overhead and improving performance.
- 🔒 Security: WebTransport benefits from the security features provided by the web platform, including transport encryption and same-origin policy.
- 🌐 Native Browser Support: WebTransport is natively supported in modern web browsers, ensuring seamless integration and enhanced performance for web applications.
Notes
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.
Simple API
async
async
Browser Integration
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 = ;
await transport.;
// Create a bidirectional stream
let stream = await transport.;
// Send data from the client to the server
await stream...;
// Read data reply from the server
let data = await stream...;
console.log;
Check out the W3C WebTransport API documentation for more details and to explore the full capabilities of WebTransport in the browser.
Getting Started
Clone the Repository
Run Full Example
The 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:
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.
Examples
Other Languages
WTransport has bindings for the following languages:
- Elixir: wtransport-elixir