pub struct FileCfg {
pub module_id: u8,
pub path: PathBuf,
pub buffer_size: usize,
pub initial_available_buffers: usize,
pub sync_interval: Option<Duration>,
pub sequential_access_hint: bool,
}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)),
sequential_access_hint: false,
};
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
sequential_access_hint: boolOptional hint to configure sequential access optimizations on the backing file
When set to true, Windows creates the file handle with FILE_FLAG_SEQUENTIAL_SCAN
instead of FILE_FLAG_RANDOM_ACCESS, and Linux applies POSIX_FADV_SEQUENTIAL