Expand description
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 throughtungstenite029, 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:
axum08foraxum0.8.xintegration.tungstenite029fortokio-tungstenite0.29.xintegration.yew022foryew0.22.xintegration.yew023foryew0.23.xintegration.web03forweb-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:
cd examples/client && trunk serveYou can run the server like this:
cd examples/server && cargo runModules§
- api
api - Shared traits for defining API types.
- axum08
axum08 - The server implementation for axum.
- client
client - The generic asynchronous client implementation.
- format
api - Runtime dispatch over the
Formats which message bodies can be encoded with. - tungstenite029
tungstenite029 - Client side implementation for
tokio-tungstenite0.29.x. - web
web03 - The generic web implementation.
- web03
web03 - Client side implementation for
web-sys0.3.x. - ws
ws - The server side of the websocket protocol.
- yew022
yew022 - Integration with yew
0.22.x. - yew023
yew023 - Integration with yew
0.23.x.
Structs§
- Atomic
Channel Id api - A
ChannelIdwhich can be shared and updated atomically. - Channel
Id api - A unique and opaque identifier for a channel over the websocket.
- Json
allocandjson - Encode the given value as JSON.
Enums§
- Format
api - The serialization format used for message bodies.