Trait avrox_storage::fs::FileSystemRead

source ·
pub trait FileSystemRead {
    type FID: Copy;

    const BLOCK_DATA_SIZE: usize;

    // Required methods
    fn read_from_location(
        &self,
        file: Self::FID,
        block: BlockNumber,
        offset: usize,
        buf: &mut [u8]
    ) -> FileSystemResult<(usize, (BlockNumber, usize))>;
    fn check_exists(&self, file: Self::FID) -> bool;
    fn get_file_size(&self, file: Self::FID) -> FileSystemResult<FileAddr>;
    fn get_free_space(&self) -> FileSystemResult<u64>;
    fn block_and_offset_for_file_location(
        &self,
        file: Self::FID,
        addr: FileAddr
    ) -> FileSystemResult<(BlockNumber, usize)>;
    fn get_next_file_in_directory(
        &self,
        parent: Option<Self::FID>,
        previous: Option<Self::FID>
    ) -> Option<Self::FID>;
}

Required Associated Types§

Required Associated Constants§

Required Methods§

source

fn read_from_location( &self, file: Self::FID, block: BlockNumber, offset: usize, buf: &mut [u8] ) -> FileSystemResult<(usize, (BlockNumber, usize))>

Read from the given file location into the buffer. The number of bytes read, and the new location at the end of the read, are returned.

This method does not guarantee to read all the bytes requested, you must pay attention to the number of bytes read returned.

source

fn check_exists(&self, file: Self::FID) -> bool

Check if the given file exists

source

fn get_file_size(&self, file: Self::FID) -> FileSystemResult<FileAddr>

Return the size of the given file

source

fn get_free_space(&self) -> FileSystemResult<u64>

Return the approximate amount of free space, in bytes

source

fn block_and_offset_for_file_location( &self, file: Self::FID, addr: FileAddr ) -> FileSystemResult<(BlockNumber, usize)>

Return the (block,offset) address for the given absolute file location (bytes since start of file).

source

fn get_next_file_in_directory( &self, parent: Option<Self::FID>, previous: Option<Self::FID> ) -> Option<Self::FID>

Return the filesystem entry following the given filesystem entry in the directory listing

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<SD> FileSystemRead for SnafusFileSystem<SD>
where SD: Storage + RandomRead,

§

type FID = FileUid

source§

const BLOCK_DATA_SIZE: usize = 250usize