Skip to main content

LogFileAccess

Trait LogFileAccess 

Source
pub trait LogFileAccess {
    // Required methods
    fn read_from_file(
        &self,
        file_num: u32,
        offset: u64,
        buf: &mut [u8],
    ) -> Result<usize>;
    fn get_file_length(&self, file_num: u32) -> Result<u64>;
    fn get_first_file_num(&self) -> Option<u32>;
    fn get_following_file_num(
        &self,
        file_num: u32,
        forward: bool,
    ) -> Option<u32>;
    fn get_file_header_prev_offset(&self, file_num: u32) -> Result<u64>;
}
Expand description

Trait for file I/O access.

Abstracts the underlying file access for testing and modularity. FileManager will implement this trait once it’s available.

Required Methods§

Source

fn read_from_file( &self, file_num: u32, offset: u64, buf: &mut [u8], ) -> Result<usize>

Read data from a log file at the specified position.

Returns the number of bytes actually read (may be less than buf.len() if end of file is reached).

Source

fn get_file_length(&self, file_num: u32) -> Result<u64>

Get the length of a log file in bytes.

Source

fn get_first_file_num(&self) -> Option<u32>

Get the first file number in the log, or None if no files exist.

Source

fn get_following_file_num(&self, file_num: u32, forward: bool) -> Option<u32>

Get the next file number after file_num (forward or backward).

Returns None if no such file exists.

Source

fn get_file_header_prev_offset(&self, file_num: u32) -> Result<u64>

Get the file header’s previous offset field for backward scanning.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§