Skip to main content

Crate musli_web

Crate musli_web 

Source
Expand description

github crates.io docs.rs

This crate provides a set of utilities for working with various web-based APIs and Müsli.

It includes support for:

  • axum Json integration, allowing you to use Müsli for serialization and deserialization in your Axum applications.
  • axum ws::Server integration, allowing you to build the server side of the websocket protocol this crate implements.
  • yew integration, allowing you to use Müsli for communicating with websocket clients using a well-defined API.
  • tokio-tungstenite integration 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:


§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

  • api is the example crate which defines API types shared between server and client.
  • server is the axum-based server implementation.
  • client is the yew client communicating with the server.

You can run the client like this:

cd examples/client && trunk serve

You can run the server like this:

cd examples/server && cargo run

Modules§

apiapi
Shared traits for defining API types.
axum08axum08
The server implementation for axum.
clientclient
The generic asynchronous client implementation.
formatapi
Runtime dispatch over the Formats which message bodies can be encoded with.
tungstenite029tungstenite029
Client side implementation for tokio-tungstenite 0.29.x.
webweb03
The generic web implementation.
web03web03
Client side implementation for web-sys 0.3.x.
wsws
The server side of the websocket protocol.
yew022yew022
Integration with yew 0.22.x.
yew023yew023
Integration with yew 0.23.x.

Structs§

AtomicChannelIdapi
A ChannelId which can be shared and updated atomically.
ChannelIdapi
A unique and opaque identifier for a channel over the websocket.
Jsonalloc and json
Encode the given value as JSON.

Enums§

Formatapi
The serialization format used for message bodies.