pub struct InsufficientBudgetError<R, Q = u64>{
pub resource: R,
pub limit: Q,
pub remaining: Q,
pub requested: Q,
}Expand description
Structured facts for a cumulative request that exceeded remaining capacity.
§Type Parameters
R- Caller-defined resource value retained for diagnostics.Q- Copyable measurement value used by the failed constraint.
§Examples
use qubit_budget::ResourceBudget;
let mut budget = ResourceBudget::new("bytes", 2_u64);
let error = budget.try_consume(3).expect_err("three bytes should not fit");
assert_eq!(error.remaining(), 2);
assert_eq!(error.requested(), 3);Fields§
§resource: RResource associated with the failed consumption request.
limit: QConfigured finite limit.
remaining: QCapacity remaining before the failed request.
requested: QQuantity requested by the failed operation.
Implementations§
Source§impl<R, Q> InsufficientBudgetError<R, Q>
impl<R, Q> InsufficientBudgetError<R, Q>
Sourcepub const fn resource(&self) -> &R
pub const fn resource(&self) -> &R
Returns the resource associated with this failure.
§Returns
Returns the resource associated with this failure.
Sourcepub fn into_resource(self) -> R
pub fn into_resource(self) -> R
Consumes this error and returns its associated resource.
§Returns
Consumes this error and returns its associated resource.
Source§impl<R, Q> InsufficientBudgetError<R, Q>where
Q: ResourceQuantity,
impl<R, Q> InsufficientBudgetError<R, Q>where
Q: ResourceQuantity,
Trait Implementations§
Source§impl<R: Clone, Q> Clone for InsufficientBudgetError<R, Q>
impl<R: Clone, Q> Clone for InsufficientBudgetError<R, Q>
Source§fn clone(&self) -> InsufficientBudgetError<R, Q>
fn clone(&self) -> InsufficientBudgetError<R, Q>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<R: Debug, Q> Debug for InsufficientBudgetError<R, Q>
impl<R: Debug, Q> Debug for InsufficientBudgetError<R, Q>
Source§impl<R, Q> Display for InsufficientBudgetError<R, Q>
impl<R, Q> Display for InsufficientBudgetError<R, Q>
impl<R: Eq, Q> Eq for InsufficientBudgetError<R, Q>
Source§impl<R, Q> Error for InsufficientBudgetError<R, Q>
impl<R, Q> Error for InsufficientBudgetError<R, Q>
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl<R, Q> From<InsufficientBudgetError<R, Q>> for BudgetError<R, Q>
impl<R, Q> From<InsufficientBudgetError<R, Q>> for BudgetError<R, Q>
Source§impl<R, Q> From<InsufficientBudgetError<R, Q>> for MeasuredBudgetError<R, Q>
impl<R, Q> From<InsufficientBudgetError<R, Q>> for MeasuredBudgetError<R, Q>
Source§impl<R: PartialEq, Q> PartialEq for InsufficientBudgetError<R, Q>
impl<R: PartialEq, Q> PartialEq for InsufficientBudgetError<R, Q>
impl<R: PartialEq, Q> StructuralPartialEq for InsufficientBudgetError<R, Q>
Auto Trait Implementations§
impl<R, Q> Freeze for InsufficientBudgetError<R, Q>
impl<R, Q> RefUnwindSafe for InsufficientBudgetError<R, Q>where
R: RefUnwindSafe,
Q: RefUnwindSafe,
impl<R, Q> Send for InsufficientBudgetError<R, Q>
impl<R, Q> Sync for InsufficientBudgetError<R, Q>
impl<R, Q> Unpin for InsufficientBudgetError<R, Q>
impl<R, Q> UnsafeUnpin for InsufficientBudgetError<R, Q>where
R: UnsafeUnpin,
Q: UnsafeUnpin,
impl<R, Q> UnwindSafe for InsufficientBudgetError<R, Q>where
R: UnwindSafe,
Q: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more