pub struct Reservation { /* private fields */ }Expand description
A reservation for a rate-limited event.
Created by Limiter::reserve(), this represents a reserved slot that must be
explicitly committed or will automatically cancel on drop.
§Examples
use tiny_counter::{EventStore, TimeUnit};
let store = EventStore::new();
// Reserve a slot
let reservation = store.limit()
.at_most("api_call", 10, TimeUnit::Hours)
.reserve("api_call")
.unwrap();
// Do some work...
// If successful, commit
reservation.commit();
// If reservation is dropped without commit, it auto-cancelsImplementations§
Source§impl Reservation
impl Reservation
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Reservation
impl !RefUnwindSafe for Reservation
impl Send for Reservation
impl Sync for Reservation
impl Unpin for Reservation
impl !UnwindSafe for Reservation
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