Skip to main content

MemoryFileSystem

Struct MemoryFileSystem 

Source
pub struct MemoryFileSystem { /* private fields */ }
Expand description

In-memory VFS shared between sync and async trait objects via Arc. Clone to hand the same state to multiple adapters.

Implementations§

Source§

impl MemoryFileSystem

Source

pub fn new() -> Self

Construct an empty in-memory filesystem.

Source

pub fn inject_error(&self, path: impl Into<PathBuf>, op: FsOp, kind: ErrorKind)

Queue a scripted error. The next operation on path whose FsOp tag matches op returns io::Error::from(kind), and the injection is consumed. Multiple injections on the same (path, op) queue in FIFO order.

Trait Implementations§

Source§

impl AsyncFileSystem for MemoryFileSystem

Source§

fn create_dir_all<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<()>>

Async variant of FileSystem::create_dir_all.
Source§

fn remove_dir_all<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<()>>

Async variant of FileSystem::remove_dir_all.
Source§

fn try_exists<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<bool>>

Async variant of FileSystem::try_exists.
Source§

fn open_read<'a>( &'a self, path: &'a Path, ) -> BoxFuture<'a, Result<Box<dyn AsyncFileRead>>>

Async variant of FileSystem::open_read.
Source§

fn open_write<'a>( &'a self, path: &'a Path, ) -> BoxFuture<'a, Result<Box<dyn AsyncFileWrite>>>

Async variant of FileSystem::open_write.
Source§

fn metadata<'a>(&'a self, path: &'a Path) -> BoxFuture<'a, Result<Metadata>>

Async variant of FileSystem::metadata.
Source§

fn rename<'a>( &'a self, from: &'a Path, to: &'a Path, ) -> BoxFuture<'a, Result<()>>

Async variant of FileSystem::rename.
Source§

impl Clone for MemoryFileSystem

Source§

fn clone(&self) -> MemoryFileSystem

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MemoryFileSystem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MemoryFileSystem

Source§

fn default() -> MemoryFileSystem

Returns the “default value” for a type. Read more
Source§

impl FileSystem for MemoryFileSystem

Source§

fn create_dir_all(&self, path: &Path) -> Result<()>

Create a directory and all missing parents. Idempotent: succeeds if the directory already exists.
Source§

fn remove_dir_all(&self, path: &Path) -> Result<()>

Remove a directory and all of its contents recursively. ErrorKind::NotFound if the path does not exist.
Source§

fn try_exists(&self, path: &Path) -> Result<bool>

Returns Ok(true) if the path exists, Ok(false) if it does not, and a non-NotFound error for any other condition (for example permission denied).
Source§

fn open_read(&self, path: &Path) -> Result<Box<dyn FileRead>>

Open an existing file for reading. ErrorKind::NotFound if the file does not exist.
Source§

fn open_write(&self, path: &Path) -> Result<Box<dyn FileWrite>>

Open a file for writing, creating it if absent and truncating it if present. Missing parent directories produce ErrorKind::NotFound.
Source§

fn metadata(&self, path: &Path) -> Result<Metadata>

Return metadata for the path. ErrorKind::NotFound if the path does not exist.
Source§

fn rename(&self, from: &Path, to: &Path) -> Result<()>

Rename (move) a file or directory. ErrorKind::NotFound if the source does not exist.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.