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
impl StorageConfigBuilder
Sourcepub const fn max_cache_size_bytes(self, size: u64) -> Self
pub const fn max_cache_size_bytes(self, size: u64) -> Self
Set maximum cache size in bytes
Sourcepub const fn max_cache_size_gb(self, size: u64) -> Self
pub const fn max_cache_size_gb(self, size: u64) -> Self
Set maximum cache size in GB
Sourcepub const fn enable_persistence(self, enable: bool) -> Self
pub const fn enable_persistence(self, enable: bool) -> Self
Enable or disable persistence
Sourcepub const fn sync_interval_secs(self, interval: u64) -> Self
pub const fn sync_interval_secs(self, interval: u64) -> Self
Set sync interval in seconds
Sourcepub const fn enable_compression(self, enable: bool) -> Self
pub const fn enable_compression(self, enable: bool) -> Self
Enable or disable compression
Sourcepub const fn gc_interval_secs(self, interval: u64) -> Self
pub const fn gc_interval_secs(self, interval: u64) -> Self
Set garbage collection interval in seconds
Sourcepub fn build(self) -> StorageConfig
pub fn build(self) -> StorageConfig
Build the configuration
Trait Implementations§
Source§impl Debug for StorageConfigBuilder
impl Debug for StorageConfigBuilder
Source§impl Default for StorageConfigBuilder
impl Default for StorageConfigBuilder
Source§fn default() -> StorageConfigBuilder
fn default() -> StorageConfigBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for StorageConfigBuilder
impl RefUnwindSafe for StorageConfigBuilder
impl Send for StorageConfigBuilder
impl Sync for StorageConfigBuilder
impl Unpin for StorageConfigBuilder
impl UnwindSafe for StorageConfigBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more