Skip to main content

vld_web/
lib.rs

1//! # vld-web — HTTP integrations for the `vld` validation library
2//!
3//! Extractors, filters and error responses that validate request data with
4//! `vld` schemas, one module per web framework. Every module is behind its
5//! feature; none is on by default:
6//!
7//! ```toml
8//! vld-web = { version = "0.8", features = ["axum"] }
9//! ```
10//!
11//! | Module | Feature | Framework |
12//! |---|---|---|
13//! | [`common`] | — | framework-agnostic parsing helpers and the shared error type, for custom adapters |
14//! | `axum` | `axum` | axum 0.8 extractors |
15//! | `actix` | `actix` | actix-web 4 extractors |
16//! | `ntex3` / `ntex4` | `ntex-3` / `ntex-4` (+ `ntex-compress`) | ntex 3 / ntex 4 extractors |
17//! | `poem` | `poem` | poem 3 extractors |
18//! | `rocket` | `rocket` | Rocket 0.5 data guards, request guards and catchers |
19//! | `salvo` | `salvo` | salvo 1 extractors |
20//! | `warp` | `warp` | warp 0.3 – 0.4 filters |
21//! | `rama` | `rama` | rama 0.4 extractors and a validation layer |
22//! | `tower` | `tower` | a Tower layer validating JSON bodies (any Tower-based framework) |
23//! | `tonic` | `tonic` | tonic 0.12 – 0.14 message and metadata validation |
24//! | `async_graphql` | `async-graphql` | async-graphql 7 input validator and errors with `extensions.issues` |
25//! | `tungstenite` | `tungstenite` | tungstenite 0.26 – 0.30 WebSocket messages (also tokio-/async-tungstenite) |
26//! | `axum::ws` | `axum-ws` | axum WebSocket messages |
27//! | `lambda` | `lambda` | AWS Lambda: `lambda_http` 1 requests and raw `lambda_runtime` events |
28//! | `rmcp` | `rmcp` | MCP tools (rmcp 3): vld-validated arguments, `isError` results with model feedback |
29//! | `rig` | `rig` | rig 0.47 tools: vld-validated arguments, schema per LLM provider |
30//!
31//! Every HTTP module answers with the same error bodies (422 / 413 / 415,
32//! see [`common#error-bodies`](common#error-bodies)) and parses query
33//! strings, forms, paths, headers and cookies by the same rules.
34//!
35//! ```ignore
36//! use vld_web::axum::{VldJson, VldQuery};
37//! ```
38//!
39//! Some features need a newer compiler than the crate's `rust-version`
40//! (see MSRV.md); cargo reports the framework's `rust-version` then.
41#![warn(missing_docs)]
42
43/// Implement `Deref`/`DerefMut` to the inner value for tuple extractors
44/// `Name<T>(pub T)`.
45#[allow(unused_macros)]
46macro_rules! impl_deref {
47    ($($name:ident),+ $(,)?) => {$(
48        impl<T> ::std::ops::Deref for $name<T> {
49            type Target = T;
50            fn deref(&self) -> &T {
51                &self.0
52            }
53        }
54        impl<T> ::std::ops::DerefMut for $name<T> {
55            fn deref_mut(&mut self) -> &mut T {
56                &mut self.0
57            }
58        }
59    )+};
60}
61#[allow(unused_imports)]
62pub(crate) use impl_deref;
63
64pub mod common;
65
66#[cfg(any(feature = "tungstenite", feature = "axum-ws"))]
67mod ws;
68
69#[cfg(feature = "actix")]
70pub mod actix;
71#[cfg(feature = "async-graphql")]
72pub mod async_graphql;
73#[cfg(feature = "axum")]
74pub mod axum;
75#[cfg(feature = "lambda")]
76pub mod lambda;
77#[cfg(feature = "ntex-3")]
78pub mod ntex3;
79#[cfg(feature = "ntex-4")]
80pub mod ntex4;
81#[cfg(feature = "poem")]
82pub mod poem;
83#[cfg(feature = "rama")]
84pub mod rama;
85#[cfg(feature = "rig")]
86pub mod rig;
87#[cfg(feature = "rmcp")]
88pub mod rmcp;
89#[cfg(feature = "rocket")]
90pub mod rocket;
91#[cfg(feature = "salvo")]
92pub mod salvo;
93#[cfg(feature = "tonic")]
94pub mod tonic;
95#[cfg(feature = "tower")]
96pub mod tower;
97#[cfg(feature = "tungstenite")]
98pub mod tungstenite;
99#[cfg(feature = "warp")]
100pub mod warp;