rightkit-db
Correct-by-default SQLite connection bootstrap for Right Suite desktop apps. It owns connection pragmas, SQLCipher key ordering, bounded read pooling, checkpointing, optimization, and optional integrity checks. It does not own app schemas, migrations, or queries.
Default writer & legacy reader opens select WAL with rollback fallback, a bounded
busy wait & journal, memory-backed temporary storage, & selected durability.
Use write_txn() for
any transaction that may write; it starts BEGIN IMMEDIATE so read-then-write
work cannot fail with an unretryable stale snapshot.
Features
bundled(default): bundled plain SQLite.sqlcipher: SQLCipher with vendored OpenSSL.sqlcipher-system: SQLCipher with system crypto (CommonCrypto on Apple, libcrypto elsewhere).cipher: internal gate enabled by either SQLCipher feature; do not enable directly.hooks: exposes rusqlite hooks for cancellation.
SQLCipher consumers must disable defaults & choose exactly one provider feature.
Both expose identical keyed-open & rekey APIs; enabling both is a compile error.
Keep provider choice compatible with existing encrypted databases:
= { = "=0.3.1", = false, = ["sqlcipher"] }
Choose DurabilityProfile::Full for user mutations that cannot be reconstructed
and DurabilityProfile::Normal for rebuildable indexes or telemetry. The
LargeWorkingSet cache profile is opt-in and currently intended for MailRight.
Also (0.3.0)
open_read_only(path)usesSQLITE_OPEN_READ_ONLY;open_existing_writer(path)usesSQLITE_OPEN_READ_WRITEwithout CREATE. Both returnrusqlite::Connection, accept paths orfile:URIs with query parameters, & refuse missing files. MatchingDbOptionsmethods use its path, key, timeout, & optional integrity check. They bypass journal selection, per-host routing, permission changes,init, optimization, & migrations. Read-only main DBs still allow SQLite TEMP tables unless callers setquery_only. Existingopen_reader()behavior stays unchanged: read-write/create bootstrap, thenquery_only.DbOptions::busy_timeout: std::time::Durationdefaults to five seconds & is installed before any bootstrap SQL, including key verification &init.open_in_memory()returns a private ephemeral connection. MatchingDbOptions::open_in_memory()retains key, timeout, initializer, cache, foreign-key, durability, optimization, & integrity options. Path, filesystem permissions, journal selection/fallback, & mmap do not apply; journal mode remainsmemory, including withWalStrict. Runmigratewithdb_path: Noneto skip filesystem backup & marker handling.MigrateOptions::version_storagedefaults toVersionStorage::UserVersion.VersionStorage::Table { table, key }useskey/valuecolumns compatible with Blueprint'smetatable. Values are decimal text; identifiers accept ASCII letters, digits, & underscores; keys are bound parameters. Missing table/key reads as zero. Table creation & version writes share each migration transaction.migration_versionreads chosen storage;rollback_to_with_storagereverses it.user_version&rollback_toretain their default storage.DbOptions::restore_from(backup_path)validates everyPRAGMA integrity_checkrow (CHECK constraints included) before opening existing live DB, then restores through SQLite's backup API. A read transaction holds validated source snapshot until copy completes. Missing/corrupt backups leave live DB untouched; missing live DB is refused. Backup must use options' SQLCipher key. Freerestore_from(options, destination, backup_path)restores into an existing mutable connection, including in-memory stores. Destination must be writable & outside any transaction; busy/locked retries are bounded by options' timeout.- Optional
hooks = ["rusqlite/hooks"]exposesprogress_handler()for cancellation through returned connections & existingrightkit_db::rusqlitere-export.rusqliteremains a caret requirement (0.40.1), compatible with consumers resolving0.40.2.
use Duration;
use ;
let mut db = new;
db.busy_timeout = from_millis;
let reader = db.open_read_only?;
let migrations = MigrateOptions ;
# Ok::
Publish only through:
right-release publish cargo --crate rightkit-db