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<usize, Self::Error>;
    fn close(&mut self, descriptor: usize) -> Result<(), Self::Error>;
    fn read(&mut self, descriptor: usize) -> Result<u8, Self::Error>;
    fn write(&mut self, descriptor: usize, 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<usize, Self::Error>

Opens a file and returns its descriptor.

Source

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

Closes a file.

Source

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

Reads a file.

Source

fn write(&mut self, descriptor: usize, 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§

Source§

impl FileSystem for MemoryFileSystem<'_>

Source§

type Path = [u8]

Source§

type PathBuf = Vec<u8, stak_file::::file_system::memory::{impl#1}::PathBuf::{constant#0}>

Source§

type Error = FileError

Source§

impl FileSystem for OsFileSystem

Source§

impl FileSystem for VoidFileSystem