Struct encryption::FileDictionaryFile [−][src]
FileDictionaryFile is used to store log style file dictionary.
Layout:
Encrypted File Header + FileDictionary Content | Record Header + Record Content | etc
Fields
base: PathBuf
name: String
append_file: Option<File>
file_dict: FileDictionary
enable_log: bool
file_rewrite_threshold: u64
removed: u64
file_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]
base: P,
name: &str,
enable_log: bool,
file_rewrite_threshold: u64
) -> Result<FileDictionaryFile>
pub fn open<P: AsRef<Path>>(
base: P,
name: &str,
enable_log: bool,
file_rewrite_threshold: u64,
skip_rewrite: bool
) -> Result<(FileDictionaryFile, FileDictionary)>
[src]
base: P,
name: &str,
enable_log: bool,
file_rewrite_threshold: u64,
skip_rewrite: bool
) -> Result<(FileDictionaryFile, FileDictionary)>
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]
fname: &str,
record_type: LogRecord
) -> Result<Vec<u8>>
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][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
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][+]
U: From<T>,
impl<T> Pointable for T
[src][+]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> Sealed<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> SendSyncUnwindSafe for T where
T: Send + Sync + UnwindSafe + ?Sized,
[src]
T: Send + Sync + UnwindSafe + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src][+]
V: MultiLane<T>,