Opening and closing
use corvid::Db;
let db = Db::open("app.corvid")?; // file-backed; created if absentlet db = Db::open_in_memory()?; // isolated ephemeral instanceDb::open
Section titled “Db::open”- Creates the file (and parent expectation: a missing parent directory is an error, not an implicit mkdir).
- Takes the storage engine’s exclusive lock: a second
Dbhandle to the same file in the same or another process fails withError::Database. One file, one handle, one process. - Refuses incompatible files via the on-disk format marker
(
Error::IncompatibleFormat) — an old file is never silently misread; migrate with dump/load.
Db::open_in_memory
Section titled “Db::open_in_memory”A purely in-memory instance — isolated from every other instance (including other in-memory ones), gone when dropped. Useful for tests, caches, scratch state.
Closing
Section titled “Closing”There is no explicit close: persistence is durable per transaction, so
dropping the handle (or exiting the process) is safe at any point. Db is
Send + Sync — share it behind an Arc across threads; writes serialize on
the storage engine’s single-writer lock, readers get MVCC snapshots.
What persists
Section titled “What persists”Reopening a file restores everything:
- documents, in every user collection,
- index definitions and on-disk index state (on-disk families are ready with no rebuild; in-RAM families rebuild lazily),
- schemas, TTL entries, graph edges and their adjacency, auto-id counters.
Listing collections
Section titled “Listing collections”# use corvid::{Db};# let db = Db::open_in_memory()?;let names = db.collections()?; // Vec<String>, user collections in name order# let _ = names;# Ok::<(), corvid::Error>(())Engine-reserved __ namespaces (edges, TTL, index definitions, adjacency)
are excluded — you see exactly your collections. A collection that was never
written may not appear (creation is lazy, on first write).
The MCP and binding surfaces
Section titled “The MCP and binding surfaces”The same lifecycle is exposed everywhere: corvid_open/corvid_open_memory
corvid_closein the C ABI,Db.open/openMemoryin corvid-node, theopen_serverMCP helpers.
Next: backup.