[][src]Struct debtsolver::Ledger

pub struct Ledger { /* fields omitted */ }

Represents a zero-sum ledger which tracks the current state of who owes money, and who is owed money. The sum of all balances must always add up to zero, since each debtor has an equivalent creditor.

Methods

impl Ledger[src]

pub fn new() -> Ledger[src]

Creates a new Ledger

pub fn add_transaction(&mut self, transaction: Transaction)[src]

Accepts a transaction and updates debtor and creditor balances in the ledger.

pub fn add_multi_party_transaction(
    &mut self,
    transaction: MultiPartyTransaction
)
[src]

pub fn settle(&mut self) -> Vec<Transaction>[src]

Returns the smallest possible set of transactions that will resolve all debts.

pub fn settle_upto(&mut self, group_size: usize) -> Vec<Transaction>[src]

Finds the smallest possible set of transactions that will resolve all debts, given a group size. This ranges between n/2 (best case) and n-1 (worst case), where n is the number of debtors and creditors.

pub fn to_vector(&self) -> Vec<(String, Money)>[src]

Trait Implementations

impl Debug for Ledger[src]

Auto Trait Implementations

impl RefUnwindSafe for Ledger

impl Send for Ledger

impl Sync for Ledger

impl Unpin for Ledger

impl UnwindSafe for Ledger

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.