db sub schema (via Arc)

This commit is contained in:
polv committed 2026-02-22 21:34:44 +07:00
1 parent 442e309a81
commit 62cb1e5902
7 files changed
+368 -340

No files matched your search

+11 -4
View File
@@ -1,24 +1,31 @@
use std::{path::Path, sync::Mutex};
use std::{
path::Path,
sync::{Arc, Mutex},
};
use rusqlite::{Connection, Result};
use crate::models::Entry;
mod yomitan;
pub use yomitan::{YomitanRow, create_schema, import_bundled_zip_file, search_yomitan};
#[derive(Clone)]
pub struct Database {
conn: Mutex<Connection>,
pub(crate) conn: Arc<Mutex<Connection>>,
}
impl Database {
pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> {
let conn = Connection::open(path)?;
Ok(Self {
conn: Mutex::new(conn),
conn: Arc::new(Mutex::new(conn)),
})
}
pub fn yomitan(&self) -> yomitan::YomitanDatabase {
yomitan::YomitanDatabase::new(self.clone())
}
pub fn init(&self) -> Result<()> {
let conn = self.conn.lock().unwrap();