pub trait StrictSchema {
// Provided method
fn strict_top_level_keys() -> Option<&'static [&'static str]> { ... }
}Expand description
Types parsed at a strict create boundary implement this so the
boundary can guard fields that serde_ignored can’t see.
The blanket-ish default returns None (“serde_ignored catches every
typo, nothing extra to check”), which is correct for any type
WITHOUT a #[serde(flatten)] field. A type that DOES flatten a
sub-struct must override it: serde deserialises a flattened parent
by buffering all fields into an internal map and handing the
leftovers to the flattened field’s deserialiser, and that buffering
is opaque to serde_ignored — so an unknown TOP-LEVEL key on a
flattening type is silently dropped instead of rejected (#924).
Overriding with the complete top-level key set (the type’s own
fields AND the flattened struct’s fields) lets the boundary reject
those keys explicitly. Nested typos are still caught by
serde_ignored as usual.
Provided Methods§
Sourcefn strict_top_level_keys() -> Option<&'static [&'static str]>
fn strict_top_level_keys() -> Option<&'static [&'static str]>
The complete set of valid top-level keys, or None when the
type has no flattened field. See the trait docs.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl StrictSchema for Manifest
Manifest has no #[serde(flatten)] field, so serde_ignored
already catches every top-level typo — the default (None) is
correct.
impl StrictSchema for Schedule
impl StrictSchema for View
View likewise has no flattened field.