pub struct FileCfg {
pub module_id: u8,
pub path: PathBuf,
pub buffer_size: usize,
pub initial_available_buffers: usize,
pub sync_interval: Option<Duration>,
}Expand description
Configurations for File
§Example
use frozen_core::file::FileCfg;
use std::time::Duration;
let cfg = FileCfg {
module_id: 1,
path: std::path::PathBuf::from("test.db"),
buffer_size: 0x100,
initial_available_buffers: 0x10,
sync_interval: Some(Duration::from_millis(0x64)),
};
assert_eq!(cfg.buffer_size, 0x100);
assert_eq!(cfg.initial_available_buffers, 0x10);
assert_eq!(cfg.sync_interval, Some(Duration::from_millis(0x64)));Fields§
§module_id: u8Identifier used while error propagation
path: PathBufAbsolute path for/of the file
NOTE: The caller must make sure that the path represents a file and all the parent directories included in the path do exists
buffer_size: usizeSize (in bytes) of a single chunk in file
A chunk is a small fixed size allocation and addressing unit used by File for all the
write/read ops
These ops are operated by index of the chunk and not the offset of the byte
NOTE: Chunk size when power of 2, is cache efficient and good for performance
initial_available_buffers: usizeNumber of chunks to pre-allocate on fs when File is initialized
Initial file length will be buffer_size * initial_available_buffers (bytes)
sync_interval: Option<Duration>Optional interval for the background sync thread
If Some(duration), a background worker thread is spawned which flushes dirty pages at this
interval; and if None, background sync is disabled and durability advances via manual sync
or forced tickets