[][src]Struct bookkeeping::Book

pub struct Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    Unit: Ord
{ /* fields omitted */ }

Represents a book.

Implementations

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    Unit: Ord
[src]

pub fn insert_account(&mut self, extra: AccountExtra) -> AccountKey[src]

Inserts an account.

pub fn insert_transaction(
    &mut self,
    transaction_index: TransactionIndex,
    extra: TransactionExtra
) where
    Unit: Ord
[src]

Creates a transaction and inserts it at an index.

Panics

  • transaction_index out of bounds.

pub fn insert_move(
    &mut self,
    transaction_index: TransactionIndex,
    move_index: MoveIndex,
    debit_account_key: AccountKey,
    credit_account_key: AccountKey,
    sum: Sum<Unit, SumNumber>,
    extra: MoveExtra
) where
    Unit: Ord
[src]

Creates a new move and inserts it into a transaction at an index.

Panics

  • transaction_index out of bounds.
  • move_index out of bounds.
  • Some of debit_account_key and credit_account_key are not in the book.
  • debit_account_key and credit_account_key are equal.
  • Some unit keys in the sum are not in the book.

pub fn get_account(&self, account_key: AccountKey) -> &AccountExtra[src]

Gets an account using a key.

Panics

  • account_key is not in the book.

pub fn accounts(&self) -> impl Iterator<Item = (AccountKey, &AccountExtra)>[src]

Gets an iterator of existing accounts in order of creation.

pub fn transactions(
    &self
) -> impl Iterator<Item = (TransactionIndex, &Transaction<Unit, SumNumber, TransactionExtra, MoveExtra>)>
[src]

Gets an iterator of existing transactions in their order.

pub fn set_account(&mut self, account_key: AccountKey, extra: AccountExtra)[src]

Sets an existing account.

Panics

  • account_key is not in the book.

pub fn set_transaction_extra(
    &mut self,
    transaction_index: TransactionIndex,
    extra: TransactionExtra
)
[src]

Sets extra data for a transaction.

Panics

  • transaction_index out of bounds.

pub fn set_move_extra(
    &mut self,
    transaction_index: TransactionIndex,
    move_index: MoveIndex,
    extra: MoveExtra
) where
    Unit: Ord
[src]

Sets extra data for a move.

Panics

  • transaction_index out of bounds.
  • move_index out of bounds.

pub fn account_balance_at_transaction<'a, BalanceNumber>(
    &'a self,
    account_key: AccountKey,
    transaction_index: TransactionIndex
) -> Balance<Unit, BalanceNumber> where
    Unit: Ord + Clone,
    BalanceNumber: Default + Sub<Output = BalanceNumber> + Add<Output = BalanceNumber> + Clone,
    SumNumber: Clone + Into<BalanceNumber>, 
[src]

Calculates the balance of an account at a provided transaction.

Providing an out of bounds transaction_index is undefined behavior.

Panics

  • account_key is not in the book.

pub fn remove_transaction(&mut self, transaction_index: TransactionIndex)[src]

Removes an existing transaction from the book.

Panics

  • transaction_index out of bounds.

pub fn remove_move(
    &mut self,
    transaction_index: TransactionIndex,
    move_index: MoveIndex
) where
    Unit: Ord
[src]

Removes an existing move from the book.

Panics

  • transaction_index out of bounds.
  • move_index out of bounds.

pub fn set_move_sum(
    &mut self,
    transaction_index: TransactionIndex,
    move_index: MoveIndex,
    sum: Sum<Unit, SumNumber>
) where
    Unit: Ord
[src]

Sets the sum of an existing move.

Panics

  • transaction_index out of bounds.
  • move_index out of bounds.

pub fn set_move_side(
    &mut self,
    transaction_index: TransactionIndex,
    move_index: MoveIndex,
    side: Side,
    account_key: AccountKey
) where
    Unit: Ord
[src]

Sets the account for one of the sides of an existing move.

Panics

  • transaction_index out of bounds.
  • move_index out of bounds.
  • account_key is not in the book.
  • side is same as other side.

Trait Implementations

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> Default for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    Unit: Ord
[src]

Auto Trait Implementations

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> RefUnwindSafe for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    AccountExtra: RefUnwindSafe,
    MoveExtra: RefUnwindSafe,
    SumNumber: RefUnwindSafe,
    TransactionExtra: RefUnwindSafe,
    Unit: RefUnwindSafe
[src]

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> Send for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    AccountExtra: Send,
    MoveExtra: Send,
    SumNumber: Send,
    TransactionExtra: Send,
    Unit: Send
[src]

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> Sync for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    AccountExtra: Sync,
    MoveExtra: Sync,
    SumNumber: Sync,
    TransactionExtra: Sync,
    Unit: Sync
[src]

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> Unpin for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    AccountExtra: Unpin,
    MoveExtra: Unpin,
    TransactionExtra: Unpin
[src]

impl<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> UnwindSafe for Book<Unit, SumNumber, AccountExtra, TransactionExtra, MoveExtra> where
    AccountExtra: UnwindSafe,
    MoveExtra: UnwindSafe,
    SumNumber: RefUnwindSafe,
    TransactionExtra: UnwindSafe,
    Unit: RefUnwindSafe
[src]

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 = Infallible

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.