StorageConfigBuilder

Struct StorageConfigBuilder 

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

Builder for StorageConfig

§Examples

Building a high-capacity storage configuration:

use chie_shared::StorageConfigBuilder;

let config = StorageConfigBuilder::new()
    .data_dir("/mnt/storage/chie")
    .max_cache_size_gb(100)
    .enable_persistence(true)
    .enable_compression(true)
    .build();

assert_eq!(config.max_cache_size_bytes, 100 * 1024 * 1024 * 1024);
assert!(config.validate().is_ok());

Building a memory-only configuration (no persistence):

use chie_shared::StorageConfigBuilder;

let config = StorageConfigBuilder::new()
    .data_dir("/tmp/chie")
    .max_cache_size_gb(5)
    .enable_persistence(false)
    .sync_interval_secs(0)  // No auto-sync
    .build();

assert!(!config.enable_persistence);
assert_eq!(config.sync_interval_secs, 0);

Implementations§

Source§

impl StorageConfigBuilder

Source

pub fn new() -> Self

Create a new builder with default values

Source

pub fn data_dir(self, dir: impl Into<String>) -> Self

Set data directory

Source

pub const fn max_cache_size_bytes(self, size: u64) -> Self

Set maximum cache size in bytes

Source

pub const fn max_cache_size_gb(self, size: u64) -> Self

Set maximum cache size in GB

Source

pub const fn enable_persistence(self, enable: bool) -> Self

Enable or disable persistence

Source

pub const fn sync_interval_secs(self, interval: u64) -> Self

Set sync interval in seconds

Source

pub const fn enable_compression(self, enable: bool) -> Self

Enable or disable compression

Source

pub const fn gc_interval_secs(self, interval: u64) -> Self

Set garbage collection interval in seconds

Source

pub fn build(self) -> StorageConfig

Build the configuration

Trait Implementations§

Source§

impl Debug for StorageConfigBuilder

Source§

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

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

impl Default for StorageConfigBuilder

Source§

fn default() -> StorageConfigBuilder

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> 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, 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.