versioned only.Expand description
Strict-decoding support: reject out-of-schema (Unknown) enum values anywhere
in a deserialized payload. See Bo4eStrict and strict::StrictError.
Strict-decoding support for BO4E payloads.
Every BO4E enum carries an Unknown forward-compatibility catch-all, so the
lenient serde deserialization path never fails on an unrecognized wire value
— it maps to Unknown. That is the right default for forward-compatibility,
but the wrong default at an ingest boundary that must reject typos, legacy
codes, or values from a newer schema.
The Bo4eStrict trait — implemented by every generated BO,
COM, enum, and by AnyBo — walks a value recursively and reports the
JSON-path of every enum field that decoded to Unknown. This turns the MaKo
“round-trip as validation” pattern into an actually-strict one:
use rubo4e::{Bo4eStrict, current::Messlokation};
// `sparte` carries a value this schema version does not define.
let body = r#"{"messlokationsId":"DE0123456789012345678901234567890","sparte":"PLASMA"}"#;
let melo: Messlokation = serde_json::from_str(body).unwrap(); // lenient decode
// One call finds it, wherever it sits in the tree:
let err = melo.ensure_known_enums().unwrap_err();
assert_eq!(err.paths, ["sparte"]);One call replaces the hand-written field == T::Unknown checks scattered across
every handler.
Structs§
- Strict
Error - The set of JSON-paths at which a payload holds an out-of-schema (
Unknown) enum value, produced byBo4eStrict::ensure_known_enums.
Functions§
- extension_
path json - Joins an extension key onto a parent JSON-path.
- field_
path - Joins a child field name onto a parent JSON-path.
- index_
path - Joins an array index onto a parent JSON-path (
parent[i]).