pub struct Ledger(/* private fields */);Expand description
What a process claims to be holding, by quantity name, in SI base units.
A BTreeMap rather than a Vec or a HashMap: names must come out in one
order for the audit report to be reproducible, and a hash map’s order is not
one order.
Implementations§
Source§impl Ledger
impl Ledger
Sourcepub fn with(self, quantity: &'static str, si_total: f64) -> Ledger
pub fn with(self, quantity: &'static str, si_total: f64) -> Ledger
Record a total. Repeating a name adds to it, since a domain made of parts reports the sum of its parts.
Sourcepub fn add(&mut self, quantity: &'static str, si_total: f64)
pub fn add(&mut self, quantity: &'static str, si_total: f64)
Add to a quantity’s total, in SI base units.
Also raises that entry’s scale to the largest contribution seen, which is what makes
a relative tolerance mean anything when the net total is near zero.
Sourcepub fn scale_of(&self, quantity: &str) -> Option<f64>
pub fn scale_of(&self, quantity: &str) -> Option<f64>
The largest single entry that went into a quantity — the scale on which rounding error in its total should be judged.
Sourcepub fn quantities(&self) -> impl Iterator<Item = (&'static str, f64)> + '_
pub fn quantities(&self) -> impl Iterator<Item = (&'static str, f64)> + '_
Names and net totals, in a fixed order.
Trait Implementations§
impl StructuralPartialEq for Ledger
Auto Trait Implementations§
impl Freeze for Ledger
impl RefUnwindSafe for Ledger
impl Send for Ledger
impl Sync for Ledger
impl Unpin for Ledger
impl UnsafeUnpin for Ledger
impl UnwindSafe for Ledger
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