pub struct Charge { /* private fields */ }Expand description
Bytes charged to a Meter (and booked with its budget), returned when
the charge drops. It rides inside whatever it paid for.
Bookkeeping. A charge holds one Permit for its own meter, and
every charge it absorbs from that meter merges into it (bytes added,
permits merged by home), so a value built from any number of charged
tables keeps one record, however its budget books it. A charge absorbed
from another meter is kept as one record per distinct meter. Neither
grows with the input: one meter and one budget home (every budget of the
core: Unbounded, crate::budget::Counting) allocate no record at
all (tests/memory_model.rs checks this under Counting).
Implementations§
Source§impl Charge
impl Charge
Sourcepub fn grow(&mut self, bytes: u64) -> Result<(), ChargeError>
pub fn grow(&mut self, bytes: u64) -> Result<(), ChargeError>
Charges bytes more to the same meter. A refusal changes nothing.
Sourcepub fn release(&mut self, bytes: u64)
pub fn release(&mut self, bytes: u64)
Returns up to bytes of this meter’s part now (what a buffer no
longer holds).
Sourcepub fn absorb(&mut self, other: Charge)
pub fn absorb(&mut self, other: Charge)
Takes other in: its bytes are returned when this charge drops. A
charge of this meter merges into this one; a charge of another meter
merges into the record this charge keeps for that meter (type docs).
Sourcepub fn records(&self) -> usize
pub fn records(&self) -> usize
How many records this charge keeps besides its own: one per other
meter it absorbed, plus its permit’s (Permit::records).