INNER CODE UNIT · Rust
open
aannoo/hcom · src/db/mod.rs:194
pub fn open() -> Result<Self> {
let hcom_dir = crate::paths::hcom_dir();
crate::paths::ensure_private_directory(&hcom_dir)
.with_context(|| format!("Failed to secure hcom directory: {}", hcom_dir.display()))?;
Self::open_at(&hcom_dir.join("hcom.db"))
}
/// Open the hcom database at a specific path with schema migration/compat.
pub fn open_at(db_path: &std::path::Path) -> Result<Self> {
let mut db = Self::open_raw(db_path)?;
db.ensure_schema()?;
Ok(db)
}
/// Open DB connection without schema checks (for testing only).
pub fn open_raw(db_path: &std::path::Path) -> Result<Self> {
#[cfg(test)]
assert_isolated_db_path(db_path);