Trait avrox_storage::fs::FileSystemWrite

source ·
pub trait FileSystemWrite: FileSystemRead {
    // Required methods
    fn open<P: Into<Self::FID>>(
        &self,
        path: P,
        options: &OpenOptions
    ) -> OxideResult<File<'_, Self>, IoError>
       where Self: Sized;
    fn create_file(&self, file: Self::FID) -> OxideResult<(), IoError>;
    fn write_at_location(
        &self,
        file: Self::FID,
        block: BlockNumber,
        offset: usize,
        buf: &[u8]
    ) -> FileSystemResult<(usize, (BlockNumber, usize))>;
    fn truncate_at(
        &self,
        file: Self::FID,
        block: BlockNumber,
        offset: usize
    ) -> FileSystemResult<()>;
    fn remove_file(&self, file: Self::FID) -> FileSystemResult<()>;
    fn sync(&self) -> FileSystemResult<()>;
}

Required Methods§

source

fn open<P: Into<Self::FID>>( &self, path: P, options: &OpenOptions ) -> OxideResult<File<'_, Self>, IoError>
where Self: Sized,

Open or create the identified file with the options given. See the OpenOptions documentation for further details.

source

fn create_file(&self, file: Self::FID) -> OxideResult<(), IoError>

Create the given file, with zero length

source

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

Write from the given buffer to the given file location. The number of bytes written, and the new location at the end of the last write, are returned.

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

source

fn truncate_at( &self, file: Self::FID, block: BlockNumber, offset: usize ) -> FileSystemResult<()>

Truncate the given file so the location given points to the end of the file. All remaining space is freed for re-allocation.

source

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

Delete the given file. The directory entry and all space associated with the file is freed for reallocation.

source

fn sync(&self) -> FileSystemResult<()>

Sync all data to the underlying storage

Object Safety§

This trait is not object safe.

Implementors§

source§

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