Skip to main content

FileSystem

Trait FileSystem 

Source
pub trait FileSystem {
    type Fd: Sized;

    // Required methods
    fn open(&mut self, path: &CStr, flags: u64) -> Result<Self::Fd, Error>;
    fn seek(&mut self, fd: &mut Self::Fd, from: SeekFrom) -> Result<u64, Error>;
    fn read(
        &mut self,
        fd: &mut Self::Fd,
        buf: &mut [u8],
    ) -> Result<usize, Error>;
    fn read_dir(
        &mut self,
        fd: &mut Self::Fd,
        buf: &mut [u8],
    ) -> Result<usize, Error>;
    fn metadata(&mut self, path: &CStr) -> Result<Metadata, Error>;
}
Expand description

File system of a user-space program.

Required Associated Types§

Required Methods§

Source

fn open(&mut self, path: &CStr, flags: u64) -> Result<Self::Fd, Error>

Open file under the provided path.

See open(2).

Source

fn seek(&mut self, fd: &mut Self::Fd, from: SeekFrom) -> Result<u64, Error>

Set the current read/write offset of the opened file.

See lseek(2).

Source

fn read(&mut self, fd: &mut Self::Fd, buf: &mut [u8]) -> Result<usize, Error>

Read data from the opened file to the provided buffer.

Returns the number of bytes read.

See read(2).

Source

fn read_dir( &mut self, fd: &mut Self::Fd, buf: &mut [u8], ) -> Result<usize, Error>

Read directory contents into the provided buffer.

The implementation is expected to call write_dir_entry with buf as the last argument for each entry in the directory.

See readdir(2).

Source

fn metadata(&mut self, path: &CStr) -> Result<Metadata, Error>

Read file metadata from the provided path.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§