Struct encryption::FileDictionaryFile[][src]

pub struct FileDictionaryFile {
    base: PathBuf,
    name: String,
    append_file: Option<File>,
    file_dict: FileDictionary,
    enable_log: bool,
    file_rewrite_threshold: u64,
    removed: u64,
    file_size: usize,
}

FileDictionaryFile is used to store log style file dictionary.

Layout:

Encrypted File Header + FileDictionary Content | Record Header + Record Content | etc

Fields

base: PathBufname: Stringappend_file: Option<File>file_dict: FileDictionaryenable_log: boolfile_rewrite_threshold: u64removed: u64file_size: usize

Implementations

impl FileDictionaryFile[src]

const RECORD_HEADER_SIZE: usize[src]

Header of record.

+----+--+--+-+----+----
|    |  |  | |    |
++---++-++-++++---++---
 ^    ^  ^  ^ ^    ^
 |    |  |  | |    + FileInfo content (variable bytes)
 |    |  |  | + File name content (variable bytes)
 |    |  |  + Log type (1 bytes)
 |    |  + FileInfo length (2 bytes)
 |    + File name length (2 bytes)
 + Crc32 (4 bytes)

pub fn new<P: AsRef<Path>>(
    base: P,
    name: &str,
    enable_log: bool,
    file_rewrite_threshold: u64
) -> Result<FileDictionaryFile>
[src]

pub fn open<P: AsRef<Path>>(
    base: P,
    name: &str,
    enable_log: bool,
    file_rewrite_threshold: u64,
    skip_rewrite: bool
) -> Result<(FileDictionaryFile, FileDictionary)>
[src]

pub fn file_path(&self) -> PathBuf[src]

Get the file path.

fn rewrite(&mut self) -> Result<()>[src]

Rewrite the log file to reduce file size and reduce the time of next recovery.

pub fn recovery(&mut self) -> Result<FileDictionary>[src]

Recovery from the log file and return FileDictionary.

pub fn insert(&mut self, name: &str, info: &FileInfo) -> Result<()>[src]

Append an insert operation to the log file.

Warning: self.write(file_dict) must be called before.

pub fn remove(&mut self, name: &str) -> Result<()>[src]

Append a remove operation to the log file.

Warning: self.write(file_dict) must be called before.

fn check_compact(&mut self) -> Result<()>[src]

This function needs to be called after each append operation to check if compact is needed.

fn convert_record_to_bytes(
    fname: &str,
    record_type: LogRecord
) -> Result<Vec<u8>>
[src]

fn parse_next_record(remained: &[u8]) -> Result<(usize, String, LogRecord)>[src]

fn update_metrics(&self)[src]

Trait Implementations

impl Debug for FileDictionaryFile[src]

Auto Trait Implementations

impl RefUnwindSafe for FileDictionaryFile

impl Send for FileDictionaryFile

impl Sync for FileDictionaryFile

impl Unpin for FileDictionaryFile

impl UnwindSafe for FileDictionaryFile

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pointable for T[src]

type Init = T

The type for initializers.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T> Sealed<T> for T where
    T: ?Sized
[src]

impl<T> SendSyncUnwindSafe for T where
    T: Send + Sync + UnwindSafe + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]