pub struct FakeLedger { /* private fields */ }Expand description
In-memory ledger for local mode execution.
Initialized with a balance derived from nanny.toml → limits.tokens.
Every debit reduces the balance. When balance hits zero, the policy stops
execution via BudgetExhausted.
No persistence. No network. No real money. The receipts are real records — they just don’t move actual funds.
Implementations§
Trait Implementations§
Source§impl Ledger for FakeLedger
impl Ledger for FakeLedger
Check whether a spend is possible without committing to it.
Called by the executor to build PolicyContext. Does not change the balance.
Source§fn debit(&mut self, amount: u64) -> Result<Receipt, LedgerError>
fn debit(&mut self, amount: u64) -> Result<Receipt, LedgerError>
Spend amount units and return a receipt.
Reduces the balance permanently. Returns an error if the balance is insufficient.
Source§fn total_spent(&self) -> u64
fn total_spent(&self) -> u64
Total tokens spent across all debits.
Auto Trait Implementations§
impl Freeze for FakeLedger
impl RefUnwindSafe for FakeLedger
impl Send for FakeLedger
impl Sync for FakeLedger
impl Unpin for FakeLedger
impl UnsafeUnpin for FakeLedger
impl UnwindSafe for FakeLedger
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