Skip to main content

FileCfg

Struct FileCfg 

Source
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: u8

Identifier used while error propagation

§path: PathBuf

Absolute 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: usize

Size (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: usize

Number 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

Trait Implementations§

Source§

impl Clone for FileCfg

Source§

fn clone(&self) -> Self

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 Debug for FileCfg

Source§

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

Formats the value using the given formatter. 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> 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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.