Added repositories into AppState

This commit is contained in:
micialware committed 2026-08-31 12:12:14 +03:00
1 parent 6c20561ede
commit 11d5144db5
9 files changed
+67 -23

No files matched your search

+20 -1
View File
@@ -10,6 +10,7 @@ use rusqlite::Connection;
use std::marker::PhantomData;
use std::ops::Deref;
use std::sync::Arc;
use crate::data_provider::sqlite::SqliteConnection;
pub trait Repository<T, D>
where
@@ -192,13 +193,31 @@ pub struct DataRepositoryInner<T: std::clone::Clone + EntityData, D: DbLayer<T>>
cache: Vec<T>,
temporal: Vec<T>,
next_temporal: u32,
connection: Arc<RwLock<Connection>>,
connection: Arc<RwLock<SqliteConnection>>,
data_layer: D,
query_manger: QueryManger<T, Self, D>,
version: u16,
shifts: u16,
}
impl<T: std::clone::Clone + EntityData, D: DbLayer<T> + std::default::Default> DataRepository<T, D> {
pub fn new(connection: Arc<RwLock<SqliteConnection>>) -> DataRepository<T, D> {
Self{
inner: Arc::new(RwLock::new(DataRepositoryInner{
cache: vec![],
temporal: vec![],
next_temporal: 0,
connection,
data_layer: Default::default(),
query_manger: QueryManger { queries: vec![] },
version: 0,
shifts: 0,
})),
}
}
}
impl<T: std::clone::Clone + EntityData, D: DbLayer<T>> Deref for DataRepository<T, D> {
type Target = Arc<RwLock<DataRepositoryInner<T, D>>>;