32 lines
932 B
Rust
32 lines
932 B
Rust
use crate::services::{SessionService};
|
|
use crate::util::{SQLiteConnectionFactory};
|
|
|
|
struct ServicesCache {
|
|
session_service: SessionService,
|
|
}
|
|
|
|
struct Services {
|
|
conn_fact: SQLiteConnectionFactory,
|
|
cache: ServicesCache,
|
|
}
|
|
|
|
impl Services {
|
|
pub fn new(conn_fact: SQLiteConnectionFactory) -> Services {
|
|
let mut tmp_conn = conn_fact.connection().unwrap();
|
|
let session_service = SessionService::from_conn(&mut tmp_conn).unwrap();
|
|
let cache = ServicesCache { session_service };
|
|
Services { conn_fact, cache }
|
|
}
|
|
|
|
pub fn get_authentication_service(&self) -> &SessionService {
|
|
&self.cache.session_service
|
|
}
|
|
|
|
pub fn get_user_service(&self) -> i32 {
|
|
// let mut conn = self.conn_fact.readonly().unwrap(); // todo; to proper 500
|
|
// let service_factory = ReadOnlyServiceFactory::new(&mut conn);
|
|
// service_factory.get_user_service()
|
|
88
|
|
}
|
|
}
|