pub struct SqliteThingStore { /* private fields */ }sqlite only.Expand description
SQLite-backed memory store.
Implementations§
Source§impl SqliteThingStore
impl SqliteThingStore
Sourcepub fn open(path: impl AsRef<Path>) -> ThingdResult<Self>
pub fn open(path: impl AsRef<Path>) -> ThingdResult<Self>
Open a SQLite database file and initialize the schema.
§Errors
Returns an error when SQLite cannot open the path or initialize schema.
Sourcepub fn open_in_memory() -> ThingdResult<Self>
pub fn open_in_memory() -> ThingdResult<Self>
Open an in-memory SQLite database and initialize the schema.
§Errors
Returns an error when SQLite cannot initialize schema.
Sourcepub fn schema_version(&self) -> ThingdResult<u32>
pub fn schema_version(&self) -> ThingdResult<u32>
Return the latest applied SQLite schema version.
§Errors
Returns an error when the migration metadata cannot be read.
Sourcepub fn wal_checkpoint(&self) -> ThingdResult<(i32, i32)>
pub fn wal_checkpoint(&self) -> ThingdResult<(i32, i32)>
Run PRAGMA wal_checkpoint(TRUNCATE) to flush the WAL into the main database.
Returns (frames_before, frames_after) where frames_after should be 0
when the checkpoint fully succeeds.
§Errors
Returns an error when SQLite fails to run the checkpoint.
Sourcepub fn close(&self) -> ThingdResult<()>
pub fn close(&self) -> ThingdResult<()>
Close the database connection after running a WAL checkpoint.
§Errors
Returns an error when the checkpoint fails.
Sourcepub fn backup_to(&self, path: &str) -> ThingdResult<()>
pub fn backup_to(&self, path: &str) -> ThingdResult<()>
Create a consistent snapshot backup using VACUUM INTO.
The backup file will contain all data at the current point in time.
The file can be opened with any SQLite client.
§Errors
Returns an error when the destination path cannot be written.