musli_web/
lib.rs

1//! [<img alt="github" src="https://img.shields.io/badge/github-udoprog/musli-8da0cb?style=for-the-badge&logo=github" height="20">](https://github.com/udoprog/musli)
2//! [<img alt="crates.io" src="https://img.shields.io/crates/v/musli-web.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/musli-web)
3//! [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-musli--web-66c2a5?style=for-the-badge&logoColor=white&logo=data:image/svg+xml;base64,PHN2ZyByb2xlPSJpbWciIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgdmlld0JveD0iMCAwIDUxMiA1MTIiPjxwYXRoIGZpbGw9IiNmNWY1ZjUiIGQ9Ik00ODguNiAyNTAuMkwzOTIgMjE0VjEwNS41YzAtMTUtOS4zLTI4LjQtMjMuNC0zMy43bC0xMDAtMzcuNWMtOC4xLTMuMS0xNy4xLTMuMS0yNS4zIDBsLTEwMCAzNy41Yy0xNC4xIDUuMy0yMy40IDE4LjctMjMuNCAzMy43VjIxNGwtOTYuNiAzNi4yQzkuMyAyNTUuNSAwIDI2OC45IDAgMjgzLjlWMzk0YzAgMTMuNiA3LjcgMjYuMSAxOS45IDMyLjJsMTAwIDUwYzEwLjEgNS4xIDIyLjEgNS4xIDMyLjIgMGwxMDMuOS01MiAxMDMuOSA1MmMxMC4xIDUuMSAyMi4xIDUuMSAzMi4yIDBsMTAwLTUwYzEyLjItNi4xIDE5LjktMTguNiAxOS45LTMyLjJWMjgzLjljMC0xNS05LjMtMjguNC0yMy40LTMzLjd6TTM1OCAyMTQuOGwtODUgMzEuOXYtNjguMmw4NS0zN3Y3My4zek0xNTQgMTA0LjFsMTAyLTM4LjIgMTAyIDM4LjJ2LjZsLTEwMiA0MS40LTEwMi00MS40di0uNnptODQgMjkxLjFsLTg1IDQyLjV2LTc5LjFsODUtMzguOHY3NS40em0wLTExMmwtMTAyIDQxLjQtMTAyLTQxLjR2LS42bDEwMi0zOC4yIDEwMiAzOC4ydi42em0yNDAgMTEybC04NSA0Mi41di03OS4xbDg1LTM4Ljh2NzUuNHptMC0xMTJsLTEwMiA0MS40LTEwMi00MS40di0uNmwxMDItMzguMiAxMDIgMzguMnYuNnoiPjwvcGF0aD48L3N2Zz4K" height="20">](https://docs.rs/musli-web)
4//!
5//! This crate provides a set of utilities for working with various web-based
6//! APIs and [Müsli].
7//!
8//! It includes support for:
9//! - [`axum`] [`Json`] integration, allowing you to use Müsli for serialization
10//!   and deserialization in your Axum applications.
11//! - [`axum`] [`ws::Server`] integration, allowing you to build the server side
12//!   of the websocket protocol this crate implements.
13//! - [`yew`] integration, allowing you to use Müsli for communicating with
14//!   websocket clients using a well-defined API.
15//!
16//! Note that the organization of the modules include the version of the corresponding
17//! crate. Unstable versions are prefixed with `0`, such as [`yew022`].
18//!
19//! See the following modules for how to use:
20//! * [`axum08`] for [`axum`] `0.8.x` integration.
21//! * [`yew021`] for [`yew`] `0.21.x` integration.
22//! * [`yew022`] for [`yew`] `0.22.x` integration.
23//! * [`web03`] for [`web-sys`] `0.3.x` integration.
24//!
25//! <br>
26//!
27//! ## Examples
28//!
29//! * [`api`] is the example crate which defines API types shared between server
30//!   and client.
31//! * [`server`] is the axum-based server implementation.
32//! * [`client`] is the yew client communicating with the server.
33//!
34//! You can run the client like this:
35//!
36//! ```sh
37//! cd examples/client && trunk serve
38//! ```
39//!
40//! You can run the server like this:
41//!
42//! ```sh
43//! cd examples/server && cargo run
44//! ```
45//!
46//! [`api`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/api/>
47//! [`axum`]: <https://docs.rs/axum>
48//! [`client`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/client/>
49//! [`Json`]: <https://docs.rs/musli-web/latest/musli-web/Json.struct.html>
50//! [`server`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/server/>
51//! [`web-sys`]: <https://docs.rs/web-sys>
52//! [`ws::Server`]: <https://docs.rs/musli-web/latest/musli_web/ws/struct.Server.html>
53//! [`yew`]: <https://yew.rs>
54//! [Müsli]: <https://github.com/udoprog/musli>
55
56#![no_std]
57#![cfg_attr(doc_cfg, feature(doc_cfg))]
58#![allow(clippy::type_complexity)]
59
60#[cfg(feature = "std")]
61extern crate std;
62
63#[cfg(feature = "alloc")]
64extern crate alloc;
65
66#[cfg(feature = "axum08")]
67mod buf;
68#[cfg(feature = "axum08")]
69use self::buf::Buf;
70
71#[cfg(all(feature = "json", feature = "alloc"))]
72mod json;
73#[cfg(all(feature = "json", feature = "alloc"))]
74#[cfg_attr(doc_cfg, doc(cfg(all(feature = "json", feature = "alloc"))))]
75pub use self::json::Json;
76
77#[cfg(feature = "api")]
78#[cfg_attr(doc_cfg, doc(cfg(feature = "api")))]
79pub mod api;
80
81#[cfg(feature = "axum08")]
82#[cfg_attr(doc_cfg, doc(cfg(feature = "axum08")))]
83pub mod axum08;
84
85#[cfg(feature = "web03")]
86#[cfg_attr(doc_cfg, doc(cfg(feature = "web03")))]
87pub mod web;
88
89#[cfg(feature = "web03")]
90#[cfg_attr(doc_cfg, doc(cfg(feature = "web03")))]
91pub mod web03;
92
93#[cfg(feature = "yew021")]
94#[cfg_attr(doc_cfg, doc(cfg(feature = "yew021")))]
95pub mod yew021;
96
97#[cfg(feature = "yew022")]
98#[cfg_attr(doc_cfg, doc(cfg(feature = "yew022")))]
99pub mod yew022;
100
101#[cfg(feature = "ws")]
102#[cfg_attr(doc_cfg, doc(cfg(feature = "ws")))]
103pub mod ws;
104
105#[doc(hidden)]
106pub mod __macros {
107    pub use core::fmt;
108}