[][src]Trait sunrise_fs::interface::filesystem::FileOperations

pub trait FileOperations: Debug + Sync + Send {
    fn read(&mut self, offset: u64, buf: &mut [u8]) -> LibUserResult<u64>;
fn write(&mut self, offset: u64, buf: &[u8]) -> LibUserResult<()>;
fn flush(&mut self) -> LibUserResult<()>;
fn set_len(&mut self, size: u64) -> LibUserResult<()>;
fn get_len(&mut self) -> LibUserResult<u64>; }

Represent the operation on a file.

Required methods

fn read(&mut self, offset: u64, buf: &mut [u8]) -> LibUserResult<u64>

Read the content of a file at a given offset in buf.

fn write(&mut self, offset: u64, buf: &[u8]) -> LibUserResult<()>

Write the content given buf at the given offset in the file. If the file is too small to hold the data and the appendable flag is set, it will resize the file and append the data. If the file is too small to hold the data and the appendable flag isn't set, this will return a FileSystemError::NoSpaceLeft.

fn flush(&mut self) -> LibUserResult<()>

Flush any data not written on the filesystem.

fn set_len(&mut self, size: u64) -> LibUserResult<()>

Resize the file with the given size. If the file isn't open with the appendable flag, it will not be extendable and will return a FileSystemError::NoSpaceLeft.

fn get_len(&mut self) -> LibUserResult<u64>

Return the current file size.

Loading content...

Implementors

impl FileOperations for FileInterface[src]

fn read(&mut self, offset: u64, buf: &mut [u8]) -> LibUserResult<u64>[src]

Read the content of a file at a given offset in buf.

Loading content...