Struct brb_dt_at2::bank::Bank[][src]

pub struct Bank<A: Ord + Hash> { /* fields omitted */ }

AT2 Bank for a particular Actor

Implementations

impl<A: Ord + Hash + Debug + Clone> Bank<A>[src]

pub fn open_account(&self, owner: A, balance: Money) -> Op<A>[src]

Open a new account.

The balance field should normally be 0, but this field enables an application to force a non-zero starting balance. Though of course other nodes must agree. This could for example be used to pre-fund a "MINT" account that spends money into existence (in other accounts) over time.

pub fn initial_balance(&self, actor: &A) -> Money[src]

Returns an account's starting balance, prior to any transfers in or out.

pub fn balance(&self, actor: &A) -> Money[src]

Returns an account's present balance.

This is presently a slow operation as the entire history of all transfers is iterated. i.e., it degrades O(n) with the size of the history.

pub fn transfer(&self, from: A, to: A, amount: Money) -> Option<Op<A>>[src]

Generates a new Transfer operation (but does not apply it)

Trait Implementations

impl<A: Ord + Hash + Debug + Clone + 'static + Serialize> BRBDataType<A> for Bank<A>[src]

type Op = Op<A>

The set of ops this data type accepts

type ValidationError = ValidationError

A validation error specific to this data type.

fn validate(
    &self,
    source: &A,
    op: &Self::Op
) -> Result<(), Self::ValidationError>
[src]

Protection against Byzantines

fn apply(&mut self, op: Self::Op)[src]

Executed once an op has been validated

impl<A: Clone + Ord + Hash> Clone for Bank<A>[src]

impl<A: Debug + Ord + Hash> Debug for Bank<A>[src]

impl<A: Eq + Ord + Hash> Eq for Bank<A>[src]

impl<A: PartialEq + Ord + Hash> PartialEq<Bank<A>> for Bank<A>[src]

impl<A: Ord + Hash> StructuralEq for Bank<A>[src]

impl<A: Ord + Hash> StructuralPartialEq for Bank<A>[src]

Auto Trait Implementations

impl<A> RefUnwindSafe for Bank<A> where
    A: RefUnwindSafe
[src]

impl<A> Send for Bank<A> where
    A: Send
[src]

impl<A> Sync for Bank<A> where
    A: Sync
[src]

impl<A> Unpin for Bank<A> where
    A: Unpin
[src]

impl<A> UnwindSafe for Bank<A> where
    A: RefUnwindSafe + UnwindSafe
[src]

Blanket Implementations

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

impl<T> BRBDT for T where
    T: BRBDataType<Actor>, 
[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> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,