Trait FileSystem

Source
pub trait FileSystem {
    type Path: ?Sized;
    type PathBuf: AsRef<Self::Path>;
    type Error: Error;

    // Required methods
    fn open(
        &mut self,
        path: &Self::Path,
        output: bool,
    ) -> Result<FileDescriptor, Self::Error>;
    fn close(&mut self, descriptor: FileDescriptor) -> Result<(), Self::Error>;
    fn read(&mut self, descriptor: FileDescriptor) -> Result<u8, Self::Error>;
    fn write(
        &mut self,
        descriptor: FileDescriptor,
        byte: u8,
    ) -> Result<(), Self::Error>;
    fn delete(&mut self, path: &Self::Path) -> Result<(), Self::Error>;
    fn exists(&self, path: &Self::Path) -> Result<bool, Self::Error>;
    fn decode_path(
        memory: &Memory<'_>,
        list: Value,
    ) -> Result<Self::PathBuf, Self::Error>;
}
Expand description

A file system.

Required Associated Types§

Source

type Path: ?Sized

A path.

Source

type PathBuf: AsRef<Self::Path>

A path buffer.

Source

type Error: Error

An error.

Required Methods§

Source

fn open( &mut self, path: &Self::Path, output: bool, ) -> Result<FileDescriptor, Self::Error>

Opens a file and returns its descriptor.

Source

fn close(&mut self, descriptor: FileDescriptor) -> Result<(), Self::Error>

Closes a file.

Source

fn read(&mut self, descriptor: FileDescriptor) -> Result<u8, Self::Error>

Reads a file.

Source

fn write( &mut self, descriptor: FileDescriptor, byte: u8, ) -> Result<(), Self::Error>

Writes a file.

Source

fn delete(&mut self, path: &Self::Path) -> Result<(), Self::Error>

Deletes a file.

Source

fn exists(&self, path: &Self::Path) -> Result<bool, Self::Error>

Checks if a file exists.

Source

fn decode_path( memory: &Memory<'_>, list: Value, ) -> Result<Self::PathBuf, Self::Error>

Decodes a path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§