collect profile features into one shared struct

This commit is contained in:
yggverse 2024-11-08 07:46:25 +02:00
parent ec7a668cd9
commit 25b63c0e02
5 changed files with 111 additions and 62 deletions

25
src/profile/database.rs Normal file
View file

@ -0,0 +1,25 @@
use sqlite::Connection;
use std::{path::Path, rc::Rc, sync::RwLock};
pub struct Database {
connection: Rc<RwLock<Connection>>,
}
impl Database {
// Constructors
pub fn new(path: &Path) -> Self {
Self {
connection: match Connection::open(path) {
Ok(connection) => Rc::new(RwLock::new(connection)),
Err(e) => panic!("Failed to connect profile database: {e}"),
},
}
}
// Getters
pub fn connection(&self) -> &Rc<RwLock<Connection>> {
&self.connection
}
}