Expand description
General storage for SQLite databases encrypted with SQLCipher.
Schema-free and brand-free: callers supply their migrations, name their database in error messages and register the tables they sync.
Key boundary: the caller owns every key. This crate only applies a raw 32-byte key it is handed (zeroizing the literals it builds); it never derives, wraps, stores, recovers or exports one, and never sees a password.
Re-exports§
pub use rusqlite;
Modules§
- files
- Private folders and files for opaque bytes (key files, settings, exports): folders 0700, files 0600 on Unix. Other platforms keep their default permissions.
- sync
- A row change log for keeping copies of a database in step.
Enums§
Functions§
- apply_
key - Apply a raw key (
PRAGMA key = "x'…'"); SQLCipher’s own logging stays off stderr. - begin
- Open a savepoint (
SAVEPOINT name). - encrypt_
plaintext_ in_ place - Encrypt an existing plaintext SQLite file in place with
key. - has_
cipher - Whether this SQLite is SQLCipher (a key would otherwise be ignored).
- migrate
- Apply
migrations[..upto]not yet recorded inschema_version, all in one transaction (any failure leaves the database as it was).applied(tx, i)runs right after migrationi(0-based) and before it is recorded: data upgrades and seed rows go there. - open
- Open (creating if needed, with a private parent folder and a file that is 0600 from the
start) and verify the key.
whatnames the database in the wrong-key error. A file this call created is removed again if opening fails. - open_
foreign_ readonly - Open someone else’s SQLite file read-only (URIs allowed), with their SQLCipher passphrase if it has one. The passphrase goes to SQLCipher as given; nothing is derived here and the key is not checked.
- open_
in_ memory - A private in-memory database (tests, scratch work).
- open_
readonly - Open an existing database read-only (no writes, no migrations) and verify the key.
- quote_
ident - Quote an SQL identifier (
"name", inner quotes doubled). - rekey
- Re-encrypt an open, keyed database with a new raw key (
PRAGMA rekey). - release
- Keep everything since
begin(RELEASE name). - rollback
- Undo everything since
beginand close the savepoint. - savepoint
- Run
fall-or-nothing: released when it returnsOk, rolled back when it returnsErr(the rollback’s own failure is ignored sof’s error is the one returned). - schema_
version - The highest applied migration (
schema_version). - snapshot_
to - Copy an open database to
destwith SQLite’s online backup, keyed withkey(an encrypted source stays encrypted).destis replaced, private from creation, and removed again if the copy fails. - table_
exists - Whether a table exists.