diff options
| author | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-04-23 10:47:53 -0400 |
|---|---|---|
| committer | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-04-23 10:47:53 -0400 |
| commit | 494780dc0594eba19d840f58b0f4bb8fa30edfd9 (patch) | |
| tree | dbd44e2251d51b1f93fd244425b4c9773f5c41b6 /src/app/store | |
| parent | 59033607b63c2c1d6e5d5b8a0321bd68075cfce4 (diff) | |
| download | equity-tracker-494780dc0594eba19d840f58b0f4bb8fa30edfd9.tar.gz equity-tracker-494780dc0594eba19d840f58b0f4bb8fa30edfd9.tar.bz2 equity-tracker-494780dc0594eba19d840f58b0f4bb8fa30edfd9.zip | |
Add layer to Context for holding data structures in memory
Diffstat (limited to 'src/app/store')
| -rw-r--r-- | src/app/store/mod.rs | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/app/store/mod.rs b/src/app/store/mod.rs index cbec171..5b06eb1 100644 --- a/src/app/store/mod.rs +++ b/src/app/store/mod.rs @@ -5,6 +5,8 @@ use miette::{Diagnostic, Result}; use sqlite::SQLiteStore; use thiserror::Error; +use records::{EquityChangeEvent, EquitySymbol, FiduciaryAccount}; + pub enum Context { SQLite(SQLiteStore), } @@ -23,21 +25,34 @@ impl Default for Context { } } +pub struct AppContext { + context: Context, + accounts: Vec<FiduciaryAccount>, + symbols: Vec<EquitySymbol>, + events: Vec<EquityChangeEvent>, +} + +impl Default for AppContext { + fn default() -> Self { + AppContext { context: Context::default(), accounts: vec![], symbols: vec![], events: vec![] } + } +} + pub trait Store { fn init(&mut self) -> Result<(), ContextError>; fn get_counter(&self) -> Result<u8, ContextError>; fn set_counter(&mut self, new_count: u8) -> Result<u8, ContextError>; } -impl Context { +impl AppContext { pub fn unwrap_store(&mut self) -> &mut impl Store { - match self { + match &mut self.context { Context::SQLite(store) => store, } } pub fn get_store(&self) -> &impl Store { - match self { + match &self.context { Context::SQLite(store) => store, } } |
