Skip to main content

BudgetedStringError

Enum BudgetedStringError 

Source
pub enum BudgetedStringError<R, E, Q = u64>
where R: Debug, E: Debug + Display, Q: Copy + Debug,
{ Budget(InsufficientBudgetError<R, Q>), Allocation(TryReserveError), Quantity { resource: R, source: QuantityConversionError, }, Render(E), InvalidUtf8(FromUtf8Error), LengthOverflow, }
Expand description

Describes why a budgeted string rendering transaction failed.

§Type Parameters

  • R - Caller-defined resource identity retained by limits and errors.
  • E - Error type returned by the caller-provided renderer.
  • Q - Exact unsigned quantity used for measurements and accounting.

§Examples

use qubit_budget::BudgetedStringError;

let error = BudgetedStringError::<&str, &str>::Render("render failed");
assert!(matches!(error, BudgetedStringError::Render("render failed")));

Variants§

§

Budget(InsufficientBudgetError<R, Q>)

The rendered prefix exceeded the remaining resource budget.

Tuple Fields

§0: InsufficientBudgetError<R, Q>

Exact resource, capacity, balance, and rejected request.

§

Allocation(TryReserveError)

The output buffer could not reserve the requested capacity.

Tuple Fields

§0: TryReserveError

Allocation failure returned by the output byte buffer.

§

Quantity

The rendered UTF-8 byte length cannot be represented by the budget quantity.

Fields

§resource: R

Resource whose accounting required the conversion.

§source: QuantityConversionError

Failed quantity conversion.

§

Render(E)

The renderer returned an error unrelated to the budget writer.

Tuple Fields

§0: E

Original error returned by the caller-provided renderer.

§

InvalidUtf8(FromUtf8Error)

The renderer produced bytes that are not valid UTF-8.

Tuple Fields

§0: FromUtf8Error

UTF-8 conversion failure retaining the rendered bytes.

§

LengthOverflow

The rendered byte length overflowed usize.

Trait Implementations§

Source§

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

Source§

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

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

impl<R, E, Q> Display for BudgetedStringError<R, E, Q>

Source§

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

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

impl<R, E, Q> Error for BudgetedStringError<R, E, Q>
where R: Debug, E: Debug + Display, Q: Copy + Debug, InsufficientBudgetError<R, Q>: Error, Self: Debug + Display,

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
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

Auto Trait Implementations§

§

impl<R, E, Q> Freeze for BudgetedStringError<R, E, Q>

§

impl<R, E, Q> RefUnwindSafe for BudgetedStringError<R, E, Q>

§

impl<R, E, Q> Send for BudgetedStringError<R, E, Q>
where InsufficientBudgetError<R, Q>: Send, R: Send, E: Send,

§

impl<R, E, Q> Sync for BudgetedStringError<R, E, Q>
where InsufficientBudgetError<R, Q>: Sync, R: Sync, E: Sync,

§

impl<R, E, Q> Unpin for BudgetedStringError<R, E, Q>

§

impl<R, E, Q> UnsafeUnpin for BudgetedStringError<R, E, Q>

§

impl<R, E, Q> UnwindSafe for BudgetedStringError<R, E, Q>

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.