Skip to main content

Ledger

Struct Ledger 

Source
pub struct Ledger { /* private fields */ }
Expand description

The tagged accounting itself. One process-global instance backs the engine (crate::ledger()); the type is public so the accounting is testable on its own instance.

Implementations§

Source§

impl Ledger

Source

pub const fn new() -> Self

A ledger with every cell at zero and no budgets set.

Source

pub fn add(&self, tag: MemTag, realm: Realm, bytes: u64)

Take on bytes under tag. For a subsystem that grows and shrinks in increments; one that knows its total should set it instead.

Source

pub fn release(&self, tag: MemTag, realm: Realm, bytes: u64)

Give up bytes under tag. Saturates at zero: a reporter that double-releases should read as holding nothing, never as holding an enormous amount.

Source

pub fn set(&self, tag: MemTag, realm: Realm, bytes: u64)

Declare the tag’s whole holding. Idempotent, so a pool that recomputes its resident bytes each frame cannot drift the way paired add/release calls can.

Source

pub fn set_budget(&self, tag: MemTag, realm: Realm, budget: Option<u64>)

The ceiling the tag is expected to stay under. None clears it.

Source

pub fn usage(&self, tag: MemTag, realm: Realm) -> TagUsage

Set (or clear, with None) the byte budget for one tag and realm.

Source

pub fn snapshot(&self) -> LedgerSnapshot

One tag’s current usage in one realm.

Source

pub fn clear(&self)

Drop every report and budget, including the peaks. For a host tearing a world down and building another, whose old numbers describe nothing.

Trait Implementations§

Source§

impl Default for Ledger

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.