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: usizeNumber of cache frames. Must be at least 1.
sync_mode: SyncModeDurability mode used by the WAL (M3). See SyncMode.
wal_size_limit: u64Maximum WAL file size in bytes. Default 64 MiB.
checkpoint_threshold: u64Frame count at which the pager auto-checkpoints. Default 1 000.
compression_mode: CompressionModePhase 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 MasterKeyBytes —
Zeroizing<[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
impl Config
Sourcepub fn with_cache_frames(self, frames: usize) -> Result<Self>
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.
Sourcepub fn with_sync_mode(self, sync_mode: SyncMode) -> Self
pub fn with_sync_mode(self, sync_mode: SyncMode) -> Self
Set the durability mode the WAL uses for every commit.
Sourcepub fn with_wal_size_limit(self, limit: u64) -> Self
pub fn with_wal_size_limit(self, limit: u64) -> Self
Set the WAL size cap in bytes.
Sourcepub fn with_checkpoint_threshold(self, frames: u64) -> Self
pub fn with_checkpoint_threshold(self, frames: u64) -> Self
Set the auto-checkpoint frame threshold.
Sourcepub fn with_compression_mode(self, mode: CompressionMode) -> Self
pub fn with_compression_mode(self, mode: CompressionMode) -> Self
Phase 3 (issue #8): set the per-pager compression mode for
new files. See CompressionMode.
Sourcepub fn with_encryption_key(self, key: Option<[u8; 32]>) -> Self
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.