From 494780dc0594eba19d840f58b0f4bb8fa30edfd9 Mon Sep 17 00:00:00 2001 From: Kevin Hoerr Date: Thu, 23 Apr 2026 10:47:53 -0400 Subject: Add layer to Context for holding data structures in memory --- src/app/store/mod.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/app/store/mod.rs') 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, + symbols: Vec, + events: Vec, +} + +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; fn set_counter(&mut self, new_count: u8) -> Result; } -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, } } -- cgit v1.3