Skip to main content

OpenOptions

Struct OpenOptions 

Source
pub struct OpenOptions {
    pub lock_timeout_ms: u32,
    pub memory_budget_bytes: Option<u64>,
    pub temp_disk_budget_bytes: Option<u64>,
    pub offline_validation: bool,
}
Expand description

Knobs for Database::open_with_options.

All fields default to the same values the convenience Database::open / [Database::open_encrypted] / etc. constructors use, so OpenOptions::default() round-trips the historical behavior exactly.

Fields§

§lock_timeout_ms: u32

Maximum time, in milliseconds, to wait for the cross-process database lock (_meta/.lock) before failing with MongrelError::DatabaseLocked.

0 (the default) preserves the historical fail-fast semantics: a single try_lock_exclusive call, no retry, no sleep. SQLite-style busy_timeout semantics kick in once this is non-zero — the open sleeps with progressively wider backoff (1ms → 10ms → 50ms) until either the lock is acquired or lock_timeout_ms elapses, at which point the open returns the same typed lock error as the fail-fast path.

Only the cross-process lock is affected. Mounted tables, page-cache misses, and WAL appends already serialize through in-process locks that handle their own contention. A second independent open in the same process always returns DatabaseLocked immediately; share the existing Arc<Database> instead.

§memory_budget_bytes: Option<u64>

Total bytes the storage core’s crate::memory::MemoryGovernor may hand out across every memory class (S1E-003). None (the default) uses DEFAULT_MEMORY_BUDGET_BYTES. The governor is a reservation accounting layer, not an allocation: this is a cap, not a preallocation.

§temp_disk_budget_bytes: Option<u64>

Total bytes of live spill files the core’s crate::spill::SpillManager allows across every query (S1E-004). None (the default) uses DEFAULT_TEMP_DISK_BUDGET_BYTES. Again a cap, not a preallocation.

§offline_validation: bool

Open the database through the special offline-validation API (spec section 5.3): any crate::storage_mode::StorageMode — including ClusterReplica, which every normal open path rejects — is opened read-only so a backup validator can inspect it. The opened core rejects every write with MongrelError::ReadOnlyReplica. This is the only way to open a cluster replica outside the cluster node runtime.

Implementations§

Source§

impl OpenOptions

Source

pub fn with_lock_timeout_ms(self, ms: u32) -> Self

Set OpenOptions::lock_timeout_ms. 0 keeps the fail-fast default; SQLite-style applications typically pick 1_000 – 5_000ms.

Source

pub fn with_memory_budget_bytes(self, bytes: u64) -> Self

Source

pub fn with_temp_disk_budget_bytes(self, bytes: u64) -> Self

Source

pub fn with_offline_validation(self, offline_validation: bool) -> Self

Set OpenOptions::offline_validation. true opens any storage mode read-only (the offline backup-validator API of spec section 5.3).

Trait Implementations§

Source§

impl Clone for OpenOptions

Source§

fn clone(&self) -> OpenOptions

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
Source§

impl Debug for OpenOptions

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OpenOptions

Source§

fn default() -> OpenOptions

Returns the “default value” for a type. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.