Skip to main content

DbOptions

Struct DbOptions 

Source
pub struct DbOptions {
    pub path: PathBuf,
    pub key: Option<Zeroizing<String>>,
    pub raw_key: Option<Zeroizing<[u8; 32]>>,
    pub profile: CacheProfile,
    pub durability: DurabilityProfile,
    pub foreign_keys: bool,
    pub integrity_check_on_open: bool,
    pub journal: JournalSelect,
    pub owner_only: bool,
    pub init: Option<ConnInit>,
    pub journal_env: Option<String>,
    pub per_host_fallback: bool,
}

Fields§

§path: PathBuf§key: Option<Zeroizing<String>>

SQLCipher passphrase-style key (base64-ish charset). See also DbOptions::raw_key.

§raw_key: Option<Zeroizing<[u8; 32]>>

SQLCipher raw 256-bit key, applied as x'<hex>' (no KDF). Takes precedence over key.

§profile: CacheProfile§durability: DurabilityProfile§foreign_keys: bool§integrity_check_on_open: bool§journal: JournalSelect§owner_only: bool

Narrow the database and its sidecars to owner-only (0600) on unix. Default on.

§init: Option<ConnInit>§journal_env: Option<String>

The app’s own kill-switch variable (e.g. CODERIGHT_SQLITE_JOURNAL_MODE), checked before JOURNAL_ENV.

§per_host_fallback: bool

When a rollback journal is in force (network mount, kill switch, or WAL refused), open the per-host sibling per_host_path instead of the requested file, so hosts sharing a network directory never share one rollback-journaled database. The requested file is not created. Default off.

Implementations§

Source§

impl DbOptions

Source

pub fn open_writer_migrated( &self, migrations: &[Migration], options: &MigrateOptions, ) -> Result<(Connection, MigrationReport)>

Open the writer and bring the schema up to date (see migrate); the pre-migration backup is keyed like the database itself.

Source§

impl DbOptions

Source

pub fn open_writer_with_key_candidates( &self, candidates: &[Zeroizing<String>], ) -> Result<(Connection, usize)>

Try each passphrase in order; the first that decrypts opens the writer.

Source

pub fn open_writer_recovering( &self, policy: RecoveryPolicy, ) -> Result<OpenOutcome>

Open the writer; if the file is unreadable and the policy allows it, quarantine it and open a fresh database at the same path.

Source§

impl DbOptions

Source

pub fn new(path: impl Into<PathBuf>) -> Self

Source

pub fn with_journal_env(self, name: impl Into<String>) -> Self

Source

pub fn with_per_host_fallback(self, on: bool) -> Self

Source

pub fn effective_path(&self) -> PathBuf

The file connections actually open: the requested path, or its per-host sibling when Self::per_host_fallback applies (a rollback journal is in force, or a writer already fell back there).

Source

pub fn with_passphrase(self, key: impl Into<String>) -> Self

Source

pub fn with_raw_key(self, key: [u8; 32]) -> Self

Source

pub fn is_keyed(&self) -> bool

Source

pub fn open_writer(&self) -> Result<Connection>

Source

pub fn open_reader(&self) -> Result<Connection>

Source

pub fn open_read_pool(&self, cap: usize) -> Result<ReadPool>

Trait Implementations§

Source§

impl Clone for DbOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.