pub struct ByteGate { /* private fields */ }Expand description
The gate. Cheap to clone-by-Arc; one per store.
Implementations§
Source§impl ByteGate
impl ByteGate
Sourcepub fn new(max_bytes: u64) -> ByteGate
pub fn new(max_bytes: u64) -> ByteGate
A gate over max_bytes (rounded up to a whole unit; at least one
unit, so a zero budget is a one-at-a-time gate rather than a
closed door).
Sourcepub async fn acquire(&self, bytes: u64) -> BytePermit
pub async fn acquire(&self, bytes: u64) -> BytePermit
Hold bytes until the returned permit drops. A request above the
budget clamps to the whole budget and proceeds once it has it.
Sourcepub fn high_water(&self) -> u64
pub fn high_water(&self) -> u64
The most bytes ever held at once.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ByteGate
impl RefUnwindSafe for ByteGate
impl Send for ByteGate
impl Sync for ByteGate
impl Unpin for ByteGate
impl UnsafeUnpin for ByteGate
impl UnwindSafe for ByteGate
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