pub enum JsonDecodeErrorSource<R, Q = usize>{
Budget {
stage: JsonDecodeStage,
raw_input_bytes: usize,
normalized_input_bytes: Option<usize>,
source: MeasuredBudgetError<R, Q>,
},
EmptyInput {
stage: JsonDecodeStage,
raw_input_bytes: usize,
normalized_input_bytes: Option<usize>,
},
InvalidUtf8 {
raw_input_bytes: usize,
valid_up_to: usize,
error_len: Option<usize>,
source: Option<Utf8Error>,
},
InvalidJson {
raw_input_bytes: usize,
normalized_input_bytes: Option<usize>,
syntax: JsonSyntaxError,
source: Option<Arc<dyn Error + Send + Sync>>,
},
UnexpectedTopLevel {
raw_input_bytes: usize,
normalized_input_bytes: Option<usize>,
expected: JsonRootKind,
actual: JsonRootKind,
},
Deserialize {
raw_input_bytes: usize,
normalized_input_bytes: Option<usize>,
line: usize,
column: usize,
source: Option<Arc<dyn Error + Send + Sync>>,
},
}Expand description
An owned semantic source extracted from a JSON decoding failure.
This enum preserves the complete structured state of exactly one failure.
It lets downstream adapters move error data into their own models with one
exhaustive match, without pairing super::JsonDecodeError::kind with
fallible source accessors. Parser and Serde sources remain present only
when decoding used super::DiagnosticPolicy::Detailed.
§Type Parameters
R- Resource identity attached to budget failures.Q- Quantity representation attached to budget failures.
§Examples
use qubit_json::decode::{JsonDecodeErrorSource, JsonDecoder};
let mut decoder = JsonDecoder::unlimited();
let error = decoder.validate_str("{").expect_err("invalid JSON must fail");
match error.into_source() {
JsonDecodeErrorSource::InvalidJson { syntax, .. } => {
assert_eq!(syntax.offset(), 1);
}
source => panic!("unexpected decoding source: {source:?}"),
}Variants§
Budget
A resource measurement was rejected.
Fields
stage: JsonDecodeStageSemantic stage where the measurement was rejected.
source: MeasuredBudgetError<R, Q>Complete measured-budget failure.
EmptyInput
Input was empty at a public boundary.
Fields
stage: JsonDecodeStageSemantic stage where emptiness was detected.
InvalidUtf8
Raw bytes were not valid UTF-8.
Fields
InvalidJson
Text was not one valid JSON document.
Fields
syntax: JsonSyntaxErrorStable scanner reason and source coordinates.
UnexpectedTopLevel
A valid document had an unexpected top-level kind.
Deserialize
A valid admitted document could not materialize the target type.
Fields
Trait Implementations§
Source§impl<R: Clone, Q> Clone for JsonDecodeErrorSource<R, Q>
impl<R: Clone, Q> Clone for JsonDecodeErrorSource<R, Q>
Source§fn clone(&self) -> JsonDecodeErrorSource<R, Q>
fn clone(&self) -> JsonDecodeErrorSource<R, Q>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more