pub struct JcsEncodeError<R, Q = usize>{ /* private fields */ }Expand description
Failure produced while encoding a JSON value as RFC 8785 JCS.
Serialization diagnostics are deliberately fixed text and never expose details returned by the canonicalizer.
§Type Parameters
Ris the resource type used by the encoder’s budget accounting.Qis the quantity type used by that accounting.
§Examples
use qubit_budget::json::JsonEncodeLimits;
use qubit_json::encode::JcsEncodeErrorKind;
use qubit_json::encode::JcsEncoder;
let limits: JsonEncodeLimits = JsonEncodeLimits::new();
let mut encoder = JcsEncoder::with_limits(limits, 0);
let error = encoder
.to_vec(&serde_json::json!({"key": "value"}))
.expect_err("zero working memory cannot render an object");
assert_eq!(error.kind(), JcsEncodeErrorKind::WorkingMemory);Implementations§
Source§impl<R, Q> JcsEncodeError<R, Q>
impl<R, Q> JcsEncodeError<R, Q>
Sourcepub const fn kind(&self) -> JcsEncodeErrorKind
pub const fn kind(&self) -> JcsEncodeErrorKind
Returns the stable failure category.
§Returns
The category identifying the retained budget, memory, serialization, or writer failure.
Sourcepub const fn budget_error(&self) -> Option<&MeasuredBudgetError<R, Q>>
pub const fn budget_error(&self) -> Option<&MeasuredBudgetError<R, Q>>
Returns the measured budget failure when resource accounting failed.
Some contains the retained accounting source; None means the error
belongs to another category.
§Returns
The retained budget error for a budget failure, or None otherwise.
Sourcepub const fn working_memory_error(&self) -> Option<&JcsWorkingMemoryError>
pub const fn working_memory_error(&self) -> Option<&JcsWorkingMemoryError>
Returns the working-memory limit failure when present.
Some contains the retained limit source; None means another failure
occurred.
§Returns
The retained working-memory failure for that category, or None
otherwise.
Sourcepub const fn serialization_error(&self) -> Option<&JsonSerializationError>
pub const fn serialization_error(&self) -> Option<&JsonSerializationError>
Returns the privacy-safe serialization failure when present.
Some contains its stable category without canonicalizer details;
None means another failure occurred.
§Returns
The privacy-safe serialization failure for that category, or None
otherwise.
Sourcepub const fn write_error(&self) -> Option<&Error>
pub const fn write_error(&self) -> Option<&Error>
Returns the destination I/O failure when present.
Some contains the writer’s I/O source; None means another failure
occurred.
§Returns
The retained writer error for that category, or None otherwise.
Trait Implementations§
Source§impl<R: Debug, Q> Debug for JcsEncodeError<R, Q>
impl<R: Debug, Q> Debug for JcsEncodeError<R, Q>
Source§impl<R, Q> Display for JcsEncodeError<R, Q>
impl<R, Q> Display for JcsEncodeError<R, Q>
Source§impl<R, Q> Error for JcsEncodeError<R, Q>
impl<R, Q> Error for JcsEncodeError<R, Q>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the retained source associated with the error category.
§Returns
The retained budget, working-memory, serialization, or writer source.
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()