musli-web 0.4.6

Types for integrating Müsli with websocket frameworks.
Documentation

musli-web

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:

  • [axum08] for axum 0.8.x integration.
  • [tungstenite029] for tokio-tungstenite 0.29.x integration.
  • [yew022] for yew 0.22.x integration.
  • [yew023] for yew 0.23.x integration.
  • [web03] for web-sys 0.3.x integration.

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