How eserde improves deserialization error reporting
mainStandard serde deserializers (like serde_json) abort as soon as the first error is encountered. This forces API consumers into a slow feedback loop of fixing one error at a time.
eserde solves this by performing a second pass over the input when an error occurs. It uses the eserde::EDeserialize trait to accumulate multiple errors across the entire payload, allowing you to report all schema violations (e.g., missing fields, type mismatches, or null values) to the user in a single response.
#[derive(Debug, eserde::Deserialize)]
struct Version {
major: u32,
minor: u32,
patch: u32,
}
#[derive(Debug, eserde::Deserialize)]
struct Package {
version: Version,
source: String,
}
let payload = r#"{
"version": {
"major": 1,
"minor": "2"
},
"source": null
}"#;
// eserde::json::from_str returns all errors found in the payload
let errors = eserde::json::from_str::<Package>(&payload).unwrap_err();
// Output will include multiple errors:
// - version.minor: invalid type: string "2", expected u32 ...
// - version: missing field `patch` ...
// - source: invalid type: null, expected a string ...