pub struct JsonDecodeError<R = JsonResource, Q = usize>{ /* private fields */ }Expand description
Failure produced by either strict or normalizing JSON decoding.
Internal variants are private so callers branch through stable semantic accessors rather than depending on scanner, normalizer, or Serde details.
§Type Parameters
R- Resource identity attached to budget failures.Q- Quantity representation attached to budget failures.
§Examples
use qubit_json::decode::{JsonDecodeError, JsonDecodeErrorKind, JsonDecoder};
use serde_json::Value;
let mut decoder = JsonDecoder::unlimited();
let error: JsonDecodeError = decoder
.decode_str::<Value>("")
.expect_err("empty input must be rejected");
assert_eq!(error.kind(), JsonDecodeErrorKind::InvalidJson);Implementations§
Source§impl<R, Q> JsonDecodeError<R, Q>
impl<R, Q> JsonDecodeError<R, Q>
Sourcepub const fn kind(&self) -> JsonDecodeErrorKind
pub const fn kind(&self) -> JsonDecodeErrorKind
Returns the stable failure category.
§Returns
The category describing which kind of decode operation failed.
Sourcepub const fn stage(&self) -> JsonDecodeStage
pub const fn stage(&self) -> JsonDecodeStage
Returns the semantic stage that produced the failure.
§Returns
The pipeline stage at which the failure was recorded.
Sourcepub const fn diagnostic_policy(&self) -> DiagnosticPolicy
pub const fn diagnostic_policy(&self) -> DiagnosticPolicy
Returns the diagnostic policy applied while constructing this error.
§Returns
The policy that determines whether input-derived details are retained.
Sourcepub const fn raw_input_bytes(&self) -> usize
pub const fn raw_input_bytes(&self) -> usize
Returns the original input length in bytes.
§Returns
The number of bytes charged for the input that caused this error.
Sourcepub const fn normalized_input_bytes(&self) -> Option<usize>
pub const fn normalized_input_bytes(&self) -> Option<usize>
Returns the normalized text length when normalization completed.
§Returns
Some(length) when normalization produced text, or None when the
failure occurred before a normalized document existed.
Sourcepub const fn line(&self) -> Option<usize>
pub const fn line(&self) -> Option<usize>
Returns the one-based error line when available.
§Returns
Some(line) for failures with source coordinates, otherwise None.
Sourcepub const fn column(&self) -> Option<usize>
pub const fn column(&self) -> Option<usize>
Returns the one-based error column when available.
§Returns
Some(column) for failures with source coordinates, otherwise None.
Sourcepub const fn syntax_error(&self) -> Option<&JsonSyntaxError>
pub const fn syntax_error(&self) -> Option<&JsonSyntaxError>
Returns the structured syntax failure for invalid JSON.
§Returns
A borrowed syntax error when parsing failed, otherwise None.
Sourcepub const fn budget_error(&self) -> Option<&MeasuredBudgetError<R, Q>>
pub const fn budget_error(&self) -> Option<&MeasuredBudgetError<R, Q>>
Returns the complete measured-budget failure when present.
§Returns
A borrowed budget error when resource accounting rejected the input,
otherwise None.
Sourcepub const fn utf8_valid_up_to(&self) -> Option<usize>
pub const fn utf8_valid_up_to(&self) -> Option<usize>
Returns the valid UTF-8 prefix length for invalid byte input.
§Returns
Some(bytes) for an invalid UTF-8 failure, or None for other failure
kinds.
Sourcepub const fn utf8_error_len(&self) -> Option<usize>
pub const fn utf8_error_len(&self) -> Option<usize>
Returns the invalid UTF-8 sequence length when known.
§Returns
The length of the invalid sequence when the decoder can determine it,
otherwise None.
Sourcepub const fn expected_top_level(&self) -> Option<JsonRootKind>
pub const fn expected_top_level(&self) -> Option<JsonRootKind>
Returns the expected top-level kind for a constrained decode failure.
§Returns
The required root kind when a constrained operation failed, otherwise
None.
Sourcepub const fn actual_top_level(&self) -> Option<JsonRootKind>
pub const fn actual_top_level(&self) -> Option<JsonRootKind>
Returns the observed top-level kind for a constrained decode failure.
§Returns
The root kind observed in the valid document, otherwise None.
Sourcepub fn into_source(self) -> JsonDecodeErrorSource<R, Q>
pub fn into_source(self) -> JsonDecodeErrorSource<R, Q>
Consumes this error and returns its owned semantic source.
Unlike the kind-specific accessors, this operation preserves the
complete mutually exclusive failure state. Input-derived third-party
sources remain present only when the decoder used
DiagnosticPolicy::Detailed.
§Returns
The structured budget, input, syntax, top-level, or deserialization source retained by this error.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for JsonDecodeError<R, Q>
impl<R: Clone, Q> Clone for JsonDecodeError<R, Q>
Source§fn clone(&self) -> JsonDecodeError<R, Q>
fn clone(&self) -> JsonDecodeError<R, Q>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<R, Q> Debug for JsonDecodeError<R, Q>
impl<R, Q> Debug for JsonDecodeError<R, Q>
Source§impl<R, Q> Display for JsonDecodeError<R, Q>where
R: Debug,
Q: ResourceQuantity,
impl<R, Q> Display for JsonDecodeError<R, Q>where
R: Debug,
Q: ResourceQuantity,
Source§impl<R, Q> Error for JsonDecodeError<R, Q>where
R: Debug + 'static,
Q: ResourceQuantity + 'static,
impl<R, Q> Error for JsonDecodeError<R, Q>where
R: Debug + 'static,
Q: ResourceQuantity + 'static,
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns budget sources unconditionally and input-derived sources only when detailed diagnostics retained them.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()