Skip to main content

moire_web/db/
mod.rs

1use std::path::{Path, PathBuf};
2
3use rusqlite::Connection;
4
5mod persist;
6mod query;
7mod schema;
8
9pub use persist::{
10    BacktraceFramePersist, StoredModuleManifestEntry, backtrace_frames_for_store,
11    into_stored_module_manifest, persist_backtrace_record, persist_connection_closed,
12    persist_connection_module_manifest, persist_connection_upsert, persist_cut_ack,
13    persist_cut_request, persist_delta_batch,
14};
15pub use query::{fetch_scope_entity_links_blocking, query_named_blocking, sql_query_blocking};
16pub use schema::{init_sqlite, load_next_connection_id};
17
18#[derive(Debug, Clone)]
19pub struct Db {
20    path: PathBuf,
21}
22
23impl Db {
24    pub fn new(path: PathBuf) -> Self {
25        Self { path }
26    }
27
28    pub fn path(&self) -> &Path {
29        &self.path
30    }
31
32    pub fn open(&self) -> Result<Connection, String> {
33        Connection::open(&self.path).map_err(|error| format!("open sqlite: {error}"))
34    }
35}