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//!
25//! Every HTTP module answers with the same error bodies (422 / 413 / 415,
26//! see [`common#error-bodies`](common#error-bodies)) and parses query
27//! strings, forms, paths, headers and cookies by the same rules.
28//!
29//! ```ignore
30//! use vld_web::axum::{VldJson, VldQuery};
31//! ```
32//!
33//! Some features need a newer compiler than the crate's `rust-version`
34//! (see MSRV.md); cargo reports the framework's `rust-version` then.
35#![warn(missing_docs)]
36
37/// Implement `Deref`/`DerefMut` to the inner value for tuple extractors
38/// `Name<T>(pub T)`.
39#[allow(unused_macros)]
40macro_rules! impl_deref {
41 ($($name:ident),+ $(,)?) => {$(
42 impl<T> ::std::ops::Deref for $name<T> {
43 type Target = T;
44 fn deref(&self) -> &T {
45 &self.0
46 }
47 }
48 impl<T> ::std::ops::DerefMut for $name<T> {
49 fn deref_mut(&mut self) -> &mut T {
50 &mut self.0
51 }
52 }
53 )+};
54}
55#[allow(unused_imports)]
56pub(crate) use impl_deref;
57
58pub mod common;
59
60#[cfg(feature = "actix")]
61pub mod actix;
62#[cfg(feature = "axum")]
63pub mod axum;
64#[cfg(feature = "ntex-3")]
65pub mod ntex3;
66#[cfg(feature = "ntex-4")]
67pub mod ntex4;
68#[cfg(feature = "poem")]
69pub mod poem;
70#[cfg(feature = "rama")]
71pub mod rama;
72#[cfg(feature = "rocket")]
73pub mod rocket;
74#[cfg(feature = "salvo")]
75pub mod salvo;
76#[cfg(feature = "tonic")]
77pub mod tonic;
78#[cfg(feature = "tower")]
79pub mod tower;
80#[cfg(feature = "warp")]
81pub mod warp;