Single-commit clean baseline after security scrub of niche-tells, project codenames, internal jargon, and contributor-email leaks. Contents: - 100 Rust crates (_primitives/_rust/) - 37 agent manifests (_manifests/) + generated specs (_generated/) - 67 user-invocable skills (skills/) - 33 hooks (hooks/) - Composition blocks (_blocks/) - Documentation (docs/, README.md) - TS adapter packages (_ts_packages/) - Assembler (_assembler/) - Roles (_roles/) - Templates (_templates/) - Forgejo CI (.forgejo/) Author: Denis Parfionovich <info@greendragon.info> License: see LICENSE.
32 lines
806 B
Rust
32 lines
806 B
Rust
//! `Store` — Connection wrapper. Single responsibility: open/migrate sqlite.
|
|
|
|
use crate::schema::migrate;
|
|
use anyhow::{Context, Result};
|
|
use rusqlite::Connection;
|
|
use std::path::Path;
|
|
|
|
pub struct Store {
|
|
conn: Connection,
|
|
}
|
|
|
|
impl Store {
|
|
pub fn open(path: &Path) -> Result<Self> {
|
|
if let Some(parent) = path.parent() {
|
|
let _ = std::fs::create_dir_all(parent);
|
|
}
|
|
let conn = Connection::open(path).context("open sqlite")?;
|
|
conn.pragma_update(None, "journal_mode", "WAL").ok();
|
|
migrate(&conn)?;
|
|
Ok(Self { conn })
|
|
}
|
|
|
|
pub fn open_memory() -> Result<Self> {
|
|
let conn = Connection::open_in_memory()?;
|
|
migrate(&conn)?;
|
|
Ok(Self { conn })
|
|
}
|
|
|
|
pub fn conn(&self) -> &Connection {
|
|
&self.conn
|
|
}
|
|
}
|