pub struct JsonSerializationError { /* private fields */ }Expand description
Privacy-safe failure produced while serializing a value as strict JSON.
The error exposes exact stable kinds and broad handling categories without retaining input values, object keys, or arbitrary third-party diagnostics.
§Examples
use qubit_json::encode::JsonIntegerSignedness;
use qubit_json::encode::JsonSerializationErrorKind;
use qubit_json::value::JsonValueEncoder;
let error = JsonValueEncoder::new()
.encode(&u128::MAX)
.expect_err("wide integer must be rejected");
assert_eq!(
error.kind(),
JsonSerializationErrorKind::IntegerOutOfRange {
signedness: JsonIntegerSignedness::Unsigned,
},
);Implementations§
Source§impl JsonSerializationError
impl JsonSerializationError
Sourcepub const fn new(kind: JsonSerializationErrorKind) -> Self
pub const fn new(kind: JsonSerializationErrorKind) -> Self
Sourcepub const fn kind(&self) -> JsonSerializationErrorKind
pub const fn kind(&self) -> JsonSerializationErrorKind
Returns the exact stable failure classification.
§Returns
The precise serialization failure kind retained by this error.
Sourcepub const fn category(&self) -> JsonSerializationErrorCategory
pub const fn category(&self) -> JsonSerializationErrorCategory
Returns the broad downstream handling category.
§Returns
The broad category that determines which class of serialization failure occurred.
Sourcepub const fn is_number_error(&self) -> bool
pub const fn is_number_error(&self) -> bool
Reports whether this failure belongs to the strict number contract.
§Returns
true when the failure concerns a JSON number; otherwise, false.
Sourcepub const fn is_map_key_error(&self) -> bool
pub const fn is_map_key_error(&self) -> bool
Reports whether this failure concerns JSON object-key representation.
§Returns
true when the failure concerns an object key; otherwise, false.
Sourcepub const fn is_raw_value_error(&self) -> bool
pub const fn is_raw_value_error(&self) -> bool
Reports whether this failure concerns a RawValue payload.
§Returns
true when the failure concerns a RawValue payload; otherwise,
false.
Sourcepub const fn is_serializer_contract_error(&self) -> bool
pub const fn is_serializer_contract_error(&self) -> bool
Reports whether a hand-written serializer violated a protocol contract.
§Returns
true when a serializer or display implementation violated the
compound protocol; otherwise, false.
Sourcepub const fn integer_signedness(&self) -> Option<JsonIntegerSignedness>
pub const fn integer_signedness(&self) -> Option<JsonIntegerSignedness>
Returns the signedness of an out-of-range integer, when applicable.
§Returns
Some(signedness) for an out-of-range integer, or None for every
other serialization failure.
Sourcepub const fn map_key_kind(&self) -> Option<JsonMapKeyKind>
pub const fn map_key_kind(&self) -> Option<JsonMapKeyKind>
Returns the rejected map-key shape, when applicable.
§Returns
Some(kind) for an unsupported map key, or None for every other
serialization failure.
Sourcepub const fn collection_kind(&self) -> Option<JsonCollectionKind>
pub const fn collection_kind(&self) -> Option<JsonCollectionKind>
Returns the collection whose count overflowed, when applicable.
§Returns
Some(kind) for a collection-length overflow, or None for every
other serialization failure.
Sourcepub const fn serializer_state_error(&self) -> Option<JsonSerializerStateError>
pub const fn serializer_state_error(&self) -> Option<JsonSerializerStateError>
Returns the exact invalid serializer state, when applicable.
§Returns
Some(reason) for an invalid serializer state, or None for every
other serialization failure.
Trait Implementations§
Source§impl Clone for JsonSerializationError
impl Clone for JsonSerializationError
Source§fn clone(&self) -> JsonSerializationError
fn clone(&self) -> JsonSerializationError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for JsonSerializationError
Source§impl Debug for JsonSerializationError
impl Debug for JsonSerializationError
Source§impl Display for JsonSerializationError
impl Display for JsonSerializationError
impl Eq for JsonSerializationError
Source§impl Error for JsonSerializationError
impl Error for JsonSerializationError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()