add: icon resolver
add: config "no_track" file list option add: rainbeam-shared -> tetratto-shared add: l10n
This commit is contained in:
parent
b6fe2fba37
commit
d2ca9e23d3
40 changed files with 1107 additions and 583 deletions
48
crates/core/src/database/drivers/sqlite.rs
Normal file
48
crates/core/src/database/drivers/sqlite.rs
Normal file
|
@ -0,0 +1,48 @@
|
|||
use crate::config::Config;
|
||||
use rusqlite::{Connection, Result};
|
||||
use std::collections::HashMap;
|
||||
use tetratto_l10n::{LangFile, read_langs};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DataManager(pub Config, pub HashMap<String, LangFile>);
|
||||
|
||||
impl DataManager {
|
||||
/// Obtain a connection to the staging database.
|
||||
pub(crate) async fn connect(&self) -> Result<Connection> {
|
||||
Ok(Connection::open(&self.0.database.name)?)
|
||||
}
|
||||
|
||||
/// Create a new [`DataManager`] (and init database).
|
||||
pub async fn new(config: Config) -> Result<Self> {
|
||||
let this = Self(config.clone(), read_langs());
|
||||
let conn = this.connect().await?;
|
||||
|
||||
conn.pragma_update(None, "journal_mode", "WAL").unwrap();
|
||||
conn.execute(super::common::CREATE_TABLE_USERS, ()).unwrap();
|
||||
|
||||
Ok(this)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "sqlite")]
|
||||
#[macro_export]
|
||||
macro_rules! get {
|
||||
($row:ident->$idx:literal($t:tt)) => {
|
||||
$row.get::<usize, $t>($idx).unwrap()
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! query_row {
|
||||
($conn:expr, $sql:expr, $params:expr, $f:expr) => {{
|
||||
let mut query = $conn.prepare($sql).unwrap();
|
||||
query.query_row($params, $f)
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! execute {
|
||||
($conn:expr, $sql:expr, $params:expr) => {
|
||||
$conn.prepare($sql).unwrap().execute($params)
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue