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 [`yew021`].
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//! * [`web03`] for [`web-sys`] `0.3.x` integration.
23//!
24//! <br>
25//!
26//! ## Examples
27//!
28//! * [`api`] is the example crate which defines API types shared between server
29//! and client.
30//! * [`server`] is the axum-based server implementation.
31//! * [`client`] is the yew client communicating with the server.
32//!
33//! You can run the client like this:
34//!
35//! ```sh
36//! cd examples/client && trunk serve
37//! ```
38//!
39//! You can run the server like this:
40//!
41//! ```sh
42//! cd examples/server && cargo run
43//! ```
44//!
45//! [`api`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/api/>
46//! [`axum`]: <https://docs.rs/axum>
47//! [`client`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/client/>
48//! [`Json`]: <https://docs.rs/musli-web/latest/musli-web/Json.struct.html>
49//! [`server`]: <https://github.com/udoprog/musli/tree/main/crates/musli-web/examples/server/>
50//! [`web-sys`]: <https://docs.rs/web-sys>
51//! [`ws::Server`]: <https://docs.rs/musli-web/latest/musli_web/ws/struct.Server.html>
52//! [`yew`]: <https://yew.rs>
53//! [Müsli]: <https://github.com/udoprog/musli>
54
55#![no_std]
56#![cfg_attr(doc_cfg, feature(doc_cfg))]
57#![allow(clippy::type_complexity)]
58
59#[cfg(feature = "std")]
60extern crate std;
61
62#[cfg(feature = "alloc")]
63extern crate alloc;
64
65#[cfg(feature = "axum08")]
66mod buf;
67#[cfg(feature = "axum08")]
68use self::buf::Buf;
69
70#[cfg(all(feature = "json", feature = "alloc"))]
71mod json;
72#[cfg(all(feature = "json", feature = "alloc"))]
73#[cfg_attr(doc_cfg, doc(cfg(all(feature = "json", feature = "alloc"))))]
74pub use self::json::Json;
75
76#[cfg(feature = "api")]
77#[cfg_attr(doc_cfg, doc(cfg(feature = "api")))]
78pub mod api;
79
80#[cfg(feature = "axum08")]
81#[cfg_attr(doc_cfg, doc(cfg(feature = "axum08")))]
82pub mod axum08;
83
84#[cfg(feature = "web03")]
85#[cfg_attr(doc_cfg, doc(cfg(feature = "web03")))]
86pub mod web;
87
88#[cfg(feature = "web03")]
89#[cfg_attr(doc_cfg, doc(cfg(feature = "web03")))]
90pub mod web03;
91
92#[cfg(feature = "yew021")]
93#[cfg_attr(doc_cfg, doc(cfg(feature = "yew021")))]
94pub mod yew021;
95
96#[cfg(feature = "ws")]
97#[cfg_attr(doc_cfg, doc(cfg(feature = "ws")))]
98pub mod ws;
99
100#[doc(hidden)]
101pub mod __macros {
102 pub use core::fmt;
103}