pub struct BudgetGroupError<R, Q = u64>{ /* private fields */ }Expand description
Failure returned by an atomic grouped budget consumption.
The index identifies the first budget, in caller-provided order, that rejected the request. No member of the group is charged when this error is returned.
§Type Parameters
R- Caller-defined resource identity retained by limits and errors.Q- Exact unsigned quantity used for measurements and accounting.
§Examples
use qubit_budget::ResourceBudget;
let mut first = ResourceBudget::new("first", 2_u64);
let mut second = ResourceBudget::new("second", 1_u64);
let error = ResourceBudget::try_consume_group(&mut [&mut first, &mut second], 2)
.expect_err("the second budget should reject the charge");
assert_eq!(error.index(), 1);
assert_eq!(first.remaining(), 2);Implementations§
Source§impl<R, Q> BudgetGroupError<R, Q>
impl<R, Q> BudgetGroupError<R, Q>
Sourcepub const fn index(&self) -> usize
pub const fn index(&self) -> usize
Returns the zero-based index of the first rejecting budget.
§Returns
Returns the zero-based index of the first rejecting budget.
Sourcepub const fn source_error(&self) -> &InsufficientBudgetError<R, Q>
pub const fn source_error(&self) -> &InsufficientBudgetError<R, Q>
Returns the structured failure from the rejecting budget.
§Returns
Returns the structured failure from the rejecting budget.
Sourcepub fn into_source_error(self) -> InsufficientBudgetError<R, Q>
pub fn into_source_error(self) -> InsufficientBudgetError<R, Q>
Consumes this error and returns the rejecting budget’s failure.
§Returns
Consumes this error and returns the rejecting budget’s failure.
Trait Implementations§
Source§impl<R: Clone, Q> Clone for BudgetGroupError<R, Q>
impl<R: Clone, Q> Clone for BudgetGroupError<R, Q>
Source§fn clone(&self) -> BudgetGroupError<R, Q>
fn clone(&self) -> BudgetGroupError<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 BudgetGroupError<R, Q>
impl<R: Debug, Q> Debug for BudgetGroupError<R, Q>
Source§impl<R, Q> Display for BudgetGroupError<R, Q>
impl<R, Q> Display for BudgetGroupError<R, Q>
impl<R: Eq, Q> Eq for BudgetGroupError<R, Q>
Source§impl<R, Q> Error for BudgetGroupError<R, Q>
impl<R, Q> Error for BudgetGroupError<R, Q>
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: PartialEq, Q> PartialEq for BudgetGroupError<R, Q>
impl<R: PartialEq, Q> PartialEq for BudgetGroupError<R, Q>
impl<R: PartialEq, Q> StructuralPartialEq for BudgetGroupError<R, Q>
Auto Trait Implementations§
impl<R, Q> Freeze for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: Freeze,
impl<R, Q> RefUnwindSafe for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: RefUnwindSafe,
impl<R, Q> Send for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: Send,
impl<R, Q> Sync for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: Sync,
impl<R, Q> Unpin for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: Unpin,
impl<R, Q> UnsafeUnpin for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, Q>: UnsafeUnpin,
impl<R, Q> UnwindSafe for BudgetGroupError<R, Q>where
InsufficientBudgetError<R, 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