Skip to main content

Crate rightkit_db

Crate rightkit_db 

Source

Re-exports§

pub use rusqlite;

Structs§

CheckpointStatus
DbOptions
Degraded
Why DbOptions::open_writer_migrated_or_degrade did not use the stored database as-is.
LegacyVersionTable
An app’s existing one-row-per-version table, read once to adopt its applied version (see MigrateOptions::import_legacy_versions). Only the highest version_column value is used.
MigrateOptions
Migration
MigrationReport
OpenOrDegrade
What DbOptions::open_writer_migrated_or_degrade returns.
OpenOutcome
PendingMarker
PooledReadConnection
QuarantineOptions
Options for quarantine_database_opts. Default matches quarantine_database.
ReadPool
A bounded pool of reader connections. Clones share one pool.
ReadPoolOptions
Options for a ReadPool. The default (ReadPoolOptions::new) matches DbOptions::open_read_pool: read-write file handles, with query_only set and verified on every reader. Build with the with_* methods; the fields are private.
RecoveryPolicy
RestoreOptions
Names and the optional check for restore_database.
RestoreReceipt
What a finished restore left behind, for a receipt.
StoreLock
A held store-wide lock (see store_lock_path). Released on drop.
UnreadableRecovery
Result of an open that may have set an unreadable or corrupt database aside.
WalCheckpointJob
A checkpoint job for one database. Share it by reference; it holds no connection.
WalCheckpointPolicy
When a WalCheckpointJob checkpoints.
WalCheckpointRun
What one WalCheckpointJob::tick did.
Zeroizing
The zeroizing wrapper that the SQLCipher key fields and key candidates use, re-exported so callers build keys without declaring their own zeroize dependency. Zeroizing is a wrapper for any Z: Zeroize type which implements a Drop handler which zeroizes dropped values.

Enums§

CacheProfile
DbError
DurabilityProfile
IntegrityCheck
Post-key, pre-pragma per-connection initializer (register functions, collations, …). Open-time integrity check, selected by DbOptions::integrity.
InterruptedRestore
What recover_interrupted_restore found and did.
JournalSelect
How the journal mode is chosen. WAL needs working shared-memory locking, which network filesystems often lack and which SQLite will silently downgrade; the default therefore verifies the mode that took effect and falls back to a rollback journal.
MoveMode
How a quarantined file leaves its original path.
QuarantineStamp
Suffix format of a quarantined database, appended to its file name.
RecoveryAction
What DbOptions::open_writer_recovering_unreadable did.
SidecarPolicy
What happens to the -wal, -shm and -journal sidecars of a quarantined database.
Step
StorageProblem
Why storage is unavailable. None of these ever leads to quarantine.
UnreadableCause
Why a database could not be read.
UnreadablePolicy
What to do with a database that cannot be read (not corrupt: see the module docs).
VersionStorage
Where migration versions are stored. Table storage uses Blueprint-compatible key TEXT PRIMARY KEY, value TEXT NOT NULL rows, leaving user_version untouched.
WalCheckpointMode
The checkpoint a tick ran.

Constants§

JOURNAL_ENV
Environment kill-switch (wal | delete | truncate) for a misclassified mount in the field. An app’s own variable (DbOptions::journal_env) is checked first.

Traits§

BackupProgress

Functions§

add_column_if_missing
Idempotent ALTER TABLE .. ADD COLUMN (SQLite has no IF NOT EXISTS for columns). table, column and decl must be literals from the app, never user input.
checkpoint_if_wal_larger_than
checkpoint_restart
PRAGMA wal_checkpoint(RESTART): copies the log into the main file like PASSIVE, waits (under the busy timeout) for readers still using the log, then the next writer starts it again from the beginning. The log file keeps its size. Use it when the database is quiet and the log is large; WalCheckpointJob decides when.
checkpoint_truncate
classify_open_failure
Classify an open-time failure that is neither corruption nor an unrelated error. None means “not in this family”: the caller returns the original error. path is the database file; it is probed (opened for reading) only to tell a permission failure from other SQLITE_CANTOPEN causes, because SQLite reports EACCES as SQLITE_CANTOPEN.
column_exists
True if table has column, including STORED/VIRTUAL generated columns (table_xinfo; table_info omits them, which made MailRight re-run an ALTER on every open).
journal_mode
The journal mode SQLite is actually running (wal, delete, …).
migrate
migration_version
Read the selected migration version without creating a table or row. Missing table/key means zero; malformed or negative versions are refused.
online_backup_to
Back source up to target. options supplies the SQLCipher key (if any) so the backup is encrypted with the same key; its path is ignored.
open_existing_writer
Default-options read-write open; never creates a missing database.
open_in_memory
Default-options private in-memory database.
open_read_only
Default-options read-only open; never creates a missing database.
optimize_boundary
optimize_on_open
pending_marker
pending_marker_started_at
Unix seconds when the pending <db>.migrating batch started, 0 for a marker written before the start time was recorded, None without a readable marker. A separate reader keeps PendingMarker constructible as before.
per_host_path
name.db -> name.h-<host>.db (extension-less names get the tag appended). Idempotent; unchanged when no host name is available.
quarantine_database
Move db and its -wal / -shm / -journal sidecars to <db>.corrupt-<unix-ms>[...]. Returns the new main-file path. Nothing is deleted.
quarantine_database_opts
quarantine_database with full QuarantineOptions. QuarantineStamp::Millis refuses an existing destination, and sidecar failures are errors for every stamp.
quarantine_database_with
quarantine_database with an explicit suffix format and sidecar policy. Refuses to overwrite an existing file at the destination. Sidecar failures are errors, not ignored: a -wal left at the original path would be replayed into the replacement database.
recover_interrupted_restore
recover_interrupted_restore_locked under the exclusive store lock. Call it before opening the database at startup: a crash inside a restore can leave the live path empty with the previous store sitting at its kept name.
recover_interrupted_restore_locked
Finish a restore a crash left half done, driven by the restore journal. No journal returns Ok(None).
remove_database_files
Delete a database file and its -wal, -shm and -journal sidecars.
replace_database
Atomically replace the database at options.path with the database at replacement.
replace_database_locked
replace_database for a caller that already holds the exclusive StoreLock for options.path (for example to do more work under the same lock).
restore_database
restore_database with the store-wide exclusive lock held for the call, waiting per lock.
restore_database_locked
The restore transaction for a caller that already holds the exclusive StoreLock.
restore_from
Validate backup_path before copying it into an already-open destination. Uses the SQLite backup API, including committed WAL contents. options supplies the backup’s key and timeout; its path is ignored. Invalid backups never touch destination. The destination must be writable and outside a transaction.
rollback_to
Revert to target by replaying each step’s down, highest first, one transaction per step. Refuses before touching anything unless every step in the range has a down.
rollback_to_with_storage
Revert using the same version storage selected for migrate.
store_lock_path
The lock file that guards the whole store behind the database at db_path: <db_path>.store-lock.
stored_version_is_newer
True when the version stored under storage is above the newest of migrations, which means a newer build wrote this database. It only reads: nothing is migrated, created or written. It does not consult MigrateOptions::import_legacy_versions.
unreadable_counter_path
Where the consecutive-failure count is kept: beside the database.
user_version
write_pending_marker
Writes the <db>.migrating marker for a batch that moves the schema from version from to to. The write is atomic and records the writing process id and the start time (unix seconds). migrate writes this same marker; pending_marker reads it back. Use it to simulate an interrupted migration in a crash test, instead of a private copy of the format.
write_txn
Start a transaction that reserves SQLite’s single writer slot up front. This keeps read-then-write work out of the unretryable BUSY_SNAPSHOT path.
write_txn_unchecked
write_txn for a caller that holds only &Connection, such as a closure-style helper. It runs BEGIN IMMEDIATE through Transaction::new_unchecked, so the reserved writer slot is the same. The borrow checker does not stop a nested transaction here: SQLite refuses the BEGIN instead. The transaction rolls back when dropped unless it is committed.

Type Aliases§

ConnInit
RestoreVerify
A check run on the placed store; Err(reason) rolls the restore back. The DbOptions are the ones given to the restore. Drop every connection the check opens before it returns.
Result