Wallet

Trait Wallet 

Source
pub trait Wallet: DisplayWallet {
    // Required methods
    fn add_account(
        &mut self,
        account: Box<dyn Account>,
    ) -> Result<&dyn Account, String>;
    fn balance(&self, currency: &str) -> Result<f64, String>;
    fn get_wallet_id(&self) -> &str;
    fn get_wallet_type(&self) -> WalletType;
    fn find_account_index_by_currency(&self, currency: &str) -> Option<usize>;
    fn get_account_number_by_index(&self, index: usize) -> Option<&str>;
    fn get_account_by_currency(&self, currency: &str) -> Option<&dyn Account>;
    fn transfer(
        &mut self,
        to_wallet: &mut dyn Wallet,
        currency: &str,
        amount: f64,
    ) -> TransferResponse;
    fn deposit(&mut self, currency: &str, amount: f64) -> AccountResponse;
    fn withdraw(
        &mut self,
        currency: &str,
        amount: f64,
    ) -> WithdrawWalletResponse;
}

Required Methods§

Source

fn add_account( &mut self, account: Box<dyn Account>, ) -> Result<&dyn Account, String>

Source

fn balance(&self, currency: &str) -> Result<f64, String>

Source

fn get_wallet_id(&self) -> &str

Source

fn get_wallet_type(&self) -> WalletType

Source

fn find_account_index_by_currency(&self, currency: &str) -> Option<usize>

Source

fn get_account_number_by_index(&self, index: usize) -> Option<&str>

Source

fn get_account_by_currency(&self, currency: &str) -> Option<&dyn Account>

Source

fn transfer( &mut self, to_wallet: &mut dyn Wallet, currency: &str, amount: f64, ) -> TransferResponse

Source

fn deposit(&mut self, currency: &str, amount: f64) -> AccountResponse

Source

fn withdraw(&mut self, currency: &str, amount: f64) -> WithdrawWalletResponse

Implementors§