pub struct ReservationSet { /* private fields */ }Expand description
An atomic, cancellation-safe reservation for several resources.
Implementations§
Source§impl ReservationSet
impl ReservationSet
Sourcepub fn amounts(&self) -> &BTreeMap<Resource, u64>
pub fn amounts(&self) -> &BTreeMap<Resource, u64>
Returns the canonical, resource-sorted reservation amounts.
Sourcepub fn commit<'a>(
self,
actual: impl IntoIterator<Item = (&'a Resource, u64)>,
) -> Result<(), BudgetError>
pub fn commit<'a>( self, actual: impl IntoIterator<Item = (&'a Resource, u64)>, ) -> Result<(), BudgetError>
Reconciles actual usage atomically and releases unused capacity.
Duplicate actual entries are combined with checked arithmetic. Omitted resources have zero actual usage. Unknown resources and arithmetic overflow fail closed by converting the full reservation set to consumed capacity before returning an error.
§Errors
Returns an error for unknown resources, duplicate-entry overflow, or actual usage beyond a reservation. Accounting is reconciled conservatively before every error is returned.
Sourcepub fn commit_all(self)
pub fn commit_all(self)
Converts every reserved amount to consumed capacity.
Trait Implementations§
Source§impl Debug for ReservationSet
impl Debug for ReservationSet
Source§impl Drop for ReservationSet
impl Drop for ReservationSet
Auto Trait Implementations§
impl Freeze for ReservationSet
impl RefUnwindSafe for ReservationSet
impl Send for ReservationSet
impl Sync for ReservationSet
impl Unpin for ReservationSet
impl UnsafeUnpin for ReservationSet
impl UnwindSafe for ReservationSet
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