Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub cache_frames: usize,
    pub sync_mode: SyncMode,
    pub wal_size_limit: u64,
    pub checkpoint_threshold: u64,
    pub compression_mode: CompressionMode,
    pub encryption_key: Option<MasterKeyBytes>,
}
Expand description

Pager construction options.

Debug is implemented manually so the encryption_key field — if present — never leaks into log output (it redacts to "<set>" or "<not set>"). The Serialize/Deserialize impls are auto-derived; serialising a Config with a key present will round-trip the bytes (callers must decide for themselves whether persisting that is safe).

Issue #31: Copy is derived only on the no-encryption build. Under the encryption feature the encryption_key field is a [zeroize::Zeroizing] that wipes the key bytes on drop; a type with drop-glue cannot be Copy (and Copy would defeat zeroization by allowing silent bitwise duplication of the key).

Fields§

§cache_frames: usize

Number of cache frames. Must be at least 1.

§sync_mode: SyncMode

Durability mode used by the WAL (M3). See SyncMode.

§wal_size_limit: u64

Maximum WAL file size in bytes. Default 64 MiB.

§checkpoint_threshold: u64

Frame count at which the pager auto-checkpoints. Default 1 000.

§compression_mode: CompressionMode

Phase 3 (issue #8): page-compression mode. See CompressionMode. Default Off.

§encryption_key: Option<MasterKeyBytes>

Phase 4 (issue #9): caller-supplied 32-byte master key for XChaCha20-Poly1305 page encryption. None (default) = unencrypted; Some(key) = encrypted (new files stamp format_minor = 2 + feature_flags bit 1; existing files must already be format_minor = 2).

Stored as a raw [u8; 32]; the per-file page key is derived via HKDF-SHA256(key, kdf_salt) at open time. Not persisted on disk.

Available regardless of the encryption Cargo feature so that public APIs (and serde round-trips) remain consistent across builds. Setting a key in a build without the encryption feature causes Pager::open to fail with Error::FormatFeatureUnsupported { feature: "encryption" } when the file is encryption-capable.

Issue #31: the inner type is MasterKeyBytesZeroizing<[u8; 32]> under the encryption feature so the bytes are wiped when this Config is dropped, or a bare [u8; 32] otherwise. The wrapper derefs to [u8; 32], so reads via .as_ref() / .as_deref() are unchanged.

Implementations§

Source§

impl Config

Source

pub fn with_cache_frames(self, frames: usize) -> Result<Self>

Set the cache capacity.

§Errors

Returns Error::InvalidArgument if frames is zero. The cache requires at least one frame to make progress.

Source

pub fn with_sync_mode(self, sync_mode: SyncMode) -> Self

Set the durability mode the WAL uses for every commit.

Source

pub fn with_wal_size_limit(self, limit: u64) -> Self

Set the WAL size cap in bytes.

Source

pub fn with_checkpoint_threshold(self, frames: u64) -> Self

Set the auto-checkpoint frame threshold.

Source

pub fn with_compression_mode(self, mode: CompressionMode) -> Self

Phase 3 (issue #8): set the per-pager compression mode for new files. See CompressionMode.

Source

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

Phase 4 (issue #9): set the caller’s 32-byte master encryption key. None clears any previously-set key. See Config::encryption_key.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

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 Config

Source§

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

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

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Config

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for Config

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,