pavex/
serialization.rs

1//! Serialization and deserialization utilities.
2
3/// A marker trait for types that perform deserialization using the strategy provided "out-of-the-box" by `serde`.
4///
5/// All types that derive `PathParams` automatically implement this trait.  
6/// It is **discouraged** to manually implement this trait for one of your types—and you should
7/// have no need to do so.
8///
9/// # Why do we need this?
10///
11/// > This is largely an implementation detail of Pavex and you don't need to worry about it
12/// > unless you are curious and want to know more about how Pavex works under the hood.
13///
14/// This trait is used by Pavex to reason about the way a type is going to be deserialized—i.e.
15/// mapping the shape of the Rust type to the expected shape of the data to be deserialized.
16///
17/// This enables Pavex to confidently detect common errors at compile time—e.g. if a type
18/// is trying to deserialize a path parameter that doesn't exist in the route template for the
19/// relevant request handler.  
20/// Doing this analysis for arbitrary types would result in false positives—e.g. a type might resort to
21/// a custom implementation of `serde::Deserialize` that does not actually look for a path parameter
22/// named as the field that we see in the type definition.  
23/// `StructuralDeserialize` acts as a tag that tells Pavex that a type should be in scope
24/// for additional static analysis and that it's OK to make certain assumptions.
25pub trait StructuralDeserialize {}