🚨 Feature: Add basic data structures
This includes structures for accounts, common account errors, and transactions
This commit is contained in:
parent
46a5c63529
commit
581c06fc2f
1 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,9 @@ use std::collections::HashMap;
|
|||
#[derive(Debug)]
|
||||
enum AccountingError {
|
||||
// Add variants here for account not found, account underfunded and account overfunded
|
||||
AccountNotFound(String) ,
|
||||
AccountUnderFunded(String, u64),
|
||||
AccountOverFunded(String, u64),
|
||||
}
|
||||
|
||||
/// A transaction type. Transactions should be able to rebuild a ledger's state
|
||||
|
@ -12,12 +15,15 @@ enum AccountingError {
|
|||
#[derive(Debug)]
|
||||
pub enum Tx {
|
||||
// Add variants for storing withdraw/deposit transactions
|
||||
Withdraw{account:String, amount:u64},
|
||||
Deposit{account:String, amount:u64},
|
||||
}
|
||||
|
||||
/// A type for managing accounts and their current currency balance
|
||||
#[derive(Debug)]
|
||||
struct Accounts {
|
||||
// Add a property `accounts` here
|
||||
accounts: HashMap<String, u64>,
|
||||
}
|
||||
|
||||
impl Accounts {
|
||||
|
|
Loading…
Reference in a new issue