Skip to main content

JcsEncodeError

Struct JcsEncodeError 

Source
pub struct JcsEncodeError<R, Q = usize>
where Q: Copy + Debug,
{ /* 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

  • R is the resource type used by the encoder’s budget accounting.
  • Q is 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>
where Q: Copy + Debug,

Source

pub const fn kind(&self) -> JcsEncodeErrorKind

Returns the stable failure category.

§Returns

The category identifying the retained budget, memory, serialization, or writer failure.

Source

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.

Source

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.

Source

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.

Source

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>
where Q: Copy + Debug + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<R, Q> Display for JcsEncodeError<R, Q>
where R: Debug, Q: Copy + Debug + Display,

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats a stable message that does not expose canonicalizer details.

§Parameters
  • formatter - Destination that receives the error message.
§Returns

Ok(()) after the message is written.

§Errors

Returns the formatter error if writing the message fails.

Source§

impl<R, Q> Error for JcsEncodeError<R, Q>
where R: Debug + 'static, Q: Copy + Debug + Display + 'static,

Source§

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

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl<R, Q> From<MeasuredBudgetError<R, Q>> for JcsEncodeError<R, Q>
where Q: Copy + Debug,

Source§

fn from(source: MeasuredBudgetError<R, Q>) -> Self

Converts a measured budget failure into a JCS encoding error.

§Parameters
  • source - Budget failure to preserve.
§Returns

A JCS error classified as a budget failure.

Auto Trait Implementations§

§

impl<R, Q = usize> !RefUnwindSafe for JcsEncodeError<R, Q>

§

impl<R, Q = usize> !UnwindSafe for JcsEncodeError<R, Q>

§

impl<R, Q> Forget for JcsEncodeError<R, Q>

§

impl<R, Q> Freeze for JcsEncodeError<R, Q>
where JcsEncodeFailure<R, Q>: Freeze,

§

impl<R, Q> Move for JcsEncodeError<R, Q>

§

impl<R, Q> Send for JcsEncodeError<R, Q>
where JcsEncodeFailure<R, Q>: Send,

§

impl<R, Q> Sync for JcsEncodeError<R, Q>
where JcsEncodeFailure<R, Q>: Sync,

§

impl<R, Q> Unpin for JcsEncodeError<R, Q>
where JcsEncodeFailure<R, Q>: Unpin,

§

impl<R, Q> UnsafeUnpin for JcsEncodeError<R, Q>
where JcsEncodeFailure<R, Q>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.