Expand description
A mail4agent_core::MailStore backed by plain SQLite (rusqlite,
bundled): versioned migrations, WAL, one transaction per mutating
method. This crate owns its own connection ([db]) – everything it
adds on top is the schema (migrations) and SqliteMailStore, the
mail4agent_core::MailStore implementation laid over it.
MailStore’s methods are synchronous and fallible – see
mail4agent-core’s own module doc comment on why a persistent store
cannot satisfy that trait any other way – so every method here goes
through Db::read_blocking / Db::write_blocking, never an async
helper: those would need a tokio runtime this trait has no way to
require of its caller.
Never call a SqliteMailStore method from inside an async task
running on a tokio runtime. read_blocking/write_blocking block
the calling thread on Db’s own mutex and panic if that thread is
itself inside a tokio task. A daemon wiring this store into async
request handling reaches it through tokio::task::spawn_blocking,
exactly as Db::read/Db::write would if this crate exposed them.
Re-exports§
pub use rusqlite;
Structs§
- Db
- Cheaply-clonable SQLite handle. Clones share the underlying
Mutex, so a single physical connection backs every clone – the same guaranteecrate::store::SqliteMailStore::db’s own doc comment relies on for letting a daemon share one connection between an “engine” store handle and a “reader” store handle. - Migration
- One versioned schema change:
(version, label, sql). Versions must be strictly increasing in the slice handed toMigrationRunner::new. - Migration
Runner - Sqlite
Mail Store - A
MailStorebacked by SQLite through this crate’s ownDb. Every mutating method below is exactly one transaction, matching the contractmail4agent_core::store’s module doc comment sets for a persistent implementation.
Enums§
- DbConfig
- Opening parameters for
Db. Only the two shapes this daemon actually needs: a file-backed path (WAL, production) or an in-memory connection (tests,SqliteMailStore::open_in_memory). - DbError
Functions§
- migrations
- This crate’s own migrations, in the order
crate::db::MigrationRunnermust apply them. A daemon runs these once against thecrate::db::Dbit hands tocrate::SqliteMailStore::new;crate::SqliteMailStore::open_in_memoryruns them itself for tests and small tools.