pub struct Store { /* private fields */ }Expand description
Clone-able handle to the store. Cheap to clone (just an mpsc::Sender);
safe to share across tasks and threads. Dropping all clones shuts the
worker down.
Implementations§
Source§impl Store
impl Store
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Store>
pub fn open(path: impl AsRef<Path>) -> Result<Store>
Open (or create) the DB at path, run migrations, enable WAL, and spawn
the writer thread. Returns once the worker is ready (the open +
migration happen synchronously on the worker and the result is awaited).
Sourcepub fn open_default() -> Result<Store>
pub fn open_default() -> Result<Store>
Open the store at the default crate::paths::db_path location. The CLI
and TUI entry points will call this; tests use
Store::open_in_memory instead.
Sourcepub fn open_in_memory() -> Result<Store>
pub fn open_in_memory() -> Result<Store>
Open an in-memory store. Test convenience; the contents vanish on drop.
Sourcepub async fn call<F, T>(&self, f: F) -> Result<T>
pub async fn call<F, T>(&self, f: F) -> Result<T>
Submit f to run on the writer thread with exclusive access to the
connection, and await its result. This is the single primitive every
context method is built on; a context function that needs a transaction
simply opens one inside f (it has the connection to itself for the
duration of the call).