[−][src]Struct debtsolver::Ledger
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]
&mut self,
transaction: MultiPartyTransaction
)
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,