Skip to main content

WalConfig

Struct WalConfig 

Source
pub struct WalConfig { /* private fields */ }
Expand description

Tunable parameters for a Wal.

WalConfig is a builder. Construct it with WalConfig::new (or Default), set the parameters you care about with the with_* methods, and pass it to Wal::open_with or Wal::with_store_and_config. The builder methods take and return self, so they chain.

New parameters are added here as later milestones land (segment size, sync policy, group-commit window). The builder shape means those additions do not break existing call sites.

§Examples

use wal_db::WalConfig;

// Cap records at 1 MiB instead of the 64 MiB default.
let config = WalConfig::new().with_max_record_size(1024 * 1024);
assert_eq!(config.max_record_size(), 1024 * 1024);

Implementations§

Source§

impl WalConfig

Source

pub const fn new() -> Self

Start from the defaults.

The only default that matters today is a 64 MiB maximum record size.

use wal_db::WalConfig;
let config = WalConfig::new();
assert_eq!(config.max_record_size(), 64 * 1024 * 1024);
Source

pub const fn with_max_record_size(self, bytes: u32) -> Self

Set the largest record the log will accept, in bytes.

Wal::append rejects any record larger than this with WalError::RecordTooLarge, and recovery rejects any on-disk length prefix that claims to be larger before reading the payload. That second use is the security-relevant one: it bounds the allocation a corrupt or hostile log can request.

use wal_db::WalConfig;
let config = WalConfig::new().with_max_record_size(4096);
assert_eq!(config.max_record_size(), 4096);
Source

pub const fn max_record_size(self) -> u32

The configured maximum record size, in bytes.

Source

pub const fn with_recovery_policy(self, policy: RecoveryPolicy) -> Self

Set how iteration reacts to a damaged record.

Defaults to RecoveryPolicy::StopAtFirstError.

use wal_db::{RecoveryPolicy, WalConfig};
let config = WalConfig::new().with_recovery_policy(RecoveryPolicy::SkipBadRecords);
assert_eq!(config.recovery_policy(), RecoveryPolicy::SkipBadRecords);
Source

pub const fn recovery_policy(self) -> RecoveryPolicy

The configured recovery policy.

Trait Implementations§

Source§

impl Clone for WalConfig

Source§

fn clone(&self) -> WalConfig

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 Copy for WalConfig

Source§

impl Debug for WalConfig

Source§

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

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

impl Default for WalConfig

Source§

fn default() -> Self

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

impl Eq for WalConfig

Source§

impl PartialEq for WalConfig

Source§

fn eq(&self, other: &WalConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for WalConfig

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<E> WithErrorCode<E> for E

Source§

fn with_code(self, code: impl Into<String>) -> CodedError<E>

Attach an error code to an error