Skip to main content

Crate mail4agent_store_sqlite

Crate mail4agent_store_sqlite 

Source
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 guarantee crate::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 to MigrationRunner::new.
MigrationRunner
SqliteMailStore
A MailStore backed by SQLite through this crate’s own Db. Every mutating method below is exactly one transaction, matching the contract mail4agent_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::MigrationRunner must apply them. A daemon runs these once against the crate::db::Db it hands to crate::SqliteMailStore::new; crate::SqliteMailStore::open_in_memory runs them itself for tests and small tools.