🚨 Feature: Add basic data structures

This includes structures for accounts, common account errors, and transactions
This commit is contained in:
James Musselman 2024-08-22 15:46:09 -05:00
parent 46a5c63529
commit 581c06fc2f
Signed by: Musselman
GPG key ID: 1DAEFF35ECB5D6DB

View file

@ -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 {