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<Option<u8>, Self::Error>;
fn write(
&mut self,
descriptor: FileDescriptor,
byte: u8,
) -> Result<(), Self::Error>;
fn flush(&mut self, descriptor: FileDescriptor) -> 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§
Required Methods§
Sourcefn open(
&mut self,
path: &Self::Path,
output: bool,
) -> Result<FileDescriptor, Self::Error>
fn open( &mut self, path: &Self::Path, output: bool, ) -> Result<FileDescriptor, Self::Error>
Opens a file and returns its descriptor.
Sourcefn read(
&mut self,
descriptor: FileDescriptor,
) -> Result<Option<u8>, Self::Error>
fn read( &mut self, descriptor: FileDescriptor, ) -> Result<Option<u8>, Self::Error>
Reads a file.
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.