mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 09:05:27 +00:00
collect profile features into one shared struct
This commit is contained in:
parent
ec7a668cd9
commit
25b63c0e02
5 changed files with 111 additions and 62 deletions
25
src/profile/database.rs
Normal file
25
src/profile/database.rs
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue