musli-web
This crate provides a set of utilities for working with various web-based APIs and Müsli.
It includes support for:
axumJsonintegration, allowing you to use Müsli for serialization and deserialization in your Axum applications.axumws::Serverintegration, allowing you to build the server side of the websocket protocol this crate implements.yewintegration, allowing you to use Müsli for communicating with websocket clients using a well-defined API.tokio-tungsteniteintegration through [tungstenite029], allowing non-browser clients to talk to the same websocket API.
Note that the organization of the modules include the version of the corresponding
crate. Unstable versions are prefixed with 0, such as [yew023].
See the following modules for how to use:
- [
axum08] foraxum0.8.xintegration. - [
tungstenite029] fortokio-tungstenite0.29.xintegration. - [
yew022] foryew0.22.xintegration. - [
yew023] foryew0.23.xintegration. - [
web03] forweb-sys0.3.xintegration.
Features
- A wasm-compatible and convenient websocket protocol with support for request-reply and broadcasts.
- Channel support allowing the server to identify the source of a message and clients to correlate messages.
- A negotiable body format, so a client can pick how much schema evolution it needs and the server adapts to it. Message envelopes use a fixed encoding so negotiation itself never depends on the outcome.
The available formats, from most compact to most capable, are
[Format::Packed], [Format::Storage], [Format::Wire] (the default, and
the least capable one which is fully upgrade safe), [Format::Descriptive]
and [Format::Json]. Each is gated behind a format-* feature.
Examples
apiis the example crate which defines API types shared between server and client.serveris the axum-based server implementation.clientis the yew client communicating with the server.
You can run the client like this:
&&
You can run the server like this:
&&