Begin implementing unshell_lib::manager functionality in server

This commit is contained in:
Michael Mikovsky
2025-12-03 10:15:20 -07:00
parent 7fb9aaf534
commit 11d9454f8c
10 changed files with 85 additions and 146 deletions
+30
View File
@@ -0,0 +1,30 @@
mod database;
mod manager;
use std::sync::{Arc, Mutex};
use unshell_lib::module::Manager;
use crate::SERVER_CONFIG;
#[derive(Clone)]
pub struct Server {
pub manager: Arc<Mutex<Manager>>,
pub db: sled::Db,
}
impl Server {
pub fn new(database: String) -> Self {
Self {
manager: Manager::start(&SERVER_CONFIG, Vec::new()),
db: sled::open(database).expect("Failed to open database"),
}
}
}
impl Drop for Server {
fn drop(&mut self) {
self.db.flush().expect("Failed to flush database on drop");
Manager::join(self.manager.clone());
}
}