Struct InMemorySys

Source
pub struct InMemorySys(/* private fields */);
Expand description

An in-memory system implementation useful for testing.

This is extremely untested and sloppily implemented. Use with extreme caution and only for testing. You will encounter bugs. Please submit fixes. I implemented this lazily and quickly.

Implementations§

Source§

impl InMemorySys

Source

pub fn set_seed(&self, seed: Option<u64>)

Source

pub fn set_time(&self, time: Option<SystemTime>)

Source

pub fn disable_thread_sleep(&self)

Makes thread sleeping a no-op.

Source

pub fn fs_insert(&self, path: impl AsRef<Path>, data: impl AsRef<[u8]>)

Source

pub fn fs_insert_json(&self, path: impl AsRef<Path>, json: Value)

Helper method for inserting json into the in-memory file system.

Trait Implementations§

Source§

impl BaseFsMetadata for InMemorySys

Source§

type Metadata = InMemoryMetadata

Source§

impl BaseFsOpen for InMemorySys

Source§

impl BaseFsReadDir for InMemorySys

Source§

type ReadDirEntry = InMemoryDirEntry

Source§

impl Clone for InMemorySys

Source§

fn clone(&self) -> InMemorySys

Returns a copy 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 InMemorySys

Source§

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

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

impl Default for InMemorySys

Source§

fn default() -> Self

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

impl EnvCacheDir for InMemorySys

Source§

impl EnvCurrentDir for InMemorySys

Source§

impl EnvHomeDir for InMemorySys

Source§

impl EnvSetUmask for InMemorySys

Source§

fn env_set_umask(&self, umask: u32) -> Result<u32>

Source§

impl EnvTempDir for InMemorySys

Source§

impl EnvUmask for InMemorySys

Source§

impl SystemRandom for InMemorySys

Source§

impl SystemTimeNow for InMemorySys

Source§

impl ThreadSleep for InMemorySys

Source§

impl BaseEnvSetCurrentDir for InMemorySys

Source§

impl BaseEnvSetVar for InMemorySys

Source§

impl BaseEnvVar for InMemorySys

Source§

impl BaseFsCanonicalize for InMemorySys

Source§

impl BaseFsChown for InMemorySys

Source§

impl BaseFsCloneFile for InMemorySys

Source§

impl BaseFsCopy for InMemorySys

Source§

impl BaseFsCreateDir for InMemorySys

Source§

impl BaseFsRead for InMemorySys

Source§

impl BaseFsRemoveDir for InMemorySys

Source§

impl BaseFsRemoveDirAll for InMemorySys

Source§

impl BaseFsRemoveFile for InMemorySys

Source§

impl BaseFsRename for InMemorySys

Source§

impl BaseFsSetFileTimes for InMemorySys

Source§

impl BaseFsSetPermissions for InMemorySys

Source§

impl BaseFsSetSymlinkFileTimes for InMemorySys

Source§

impl BaseFsSymlinkChown for InMemorySys

Source§

impl BaseFsSymlinkDir for InMemorySys

Source§

impl BaseFsSymlinkFile for InMemorySys

Source§

impl BaseFsWrite for InMemorySys

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> EnvSetCurrentDir for T

Source§

fn env_set_current_dir(&self, path: impl AsRef<Path>) -> Result<()>

Source§

impl<T> EnvSetVar for T
where T: BaseEnvSetVar,

Source§

fn env_set_var(&self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>)

Source§

impl<T> EnvVar for T
where T: BaseEnvVar,

Source§

fn env_var_os(&self, key: impl AsRef<OsStr>) -> Option<OsString>

Source§

fn env_var(&self, key: impl AsRef<OsStr>) -> Result<String, VarError>

Source§

fn env_var_path(&self, key: impl AsRef<OsStr>) -> Option<PathBuf>

Helper to get a path from an environment variable.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FsCanonicalize for T

Source§

fn fs_canonicalize(&self, path: impl AsRef<Path>) -> Result<PathBuf>

Source§

impl<T> FsChown for T
where T: BaseFsChown,

Source§

fn fs_chown( &self, path: impl AsRef<Path>, uid: Option<u32>, gid: Option<u32>, ) -> Result<()>

Source§

impl<T> FsCloneFile for T
where T: BaseFsCloneFile,

Source§

fn fs_clone_file( &self, from: impl AsRef<Path>, to: impl AsRef<Path>, ) -> Result<()>

Source§

impl<T> FsCopy for T
where T: BaseFsCopy,

Source§

fn fs_copy(&self, from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<u64>

Source§

impl<T> FsCreateDir for T
where T: BaseFsCreateDir,

Source§

fn fs_create_dir( &self, path: impl AsRef<Path>, options: &CreateDirOptions, ) -> Result<()>

Source§

impl<T> FsCreateDirAll for T
where T: BaseFsCreateDir,

Source§

fn fs_create_dir_all(&self, path: impl AsRef<Path>) -> Result<()>

Source§

impl<T> FsMetadata for T
where T: BaseFsMetadata,

Source§

fn fs_metadata(&self, path: impl AsRef<Path>) -> Result<Self::Metadata>

Source§

fn fs_is_file(&self, path: impl AsRef<Path>) -> Result<bool>

Source§

fn fs_is_file_no_err(&self, path: impl AsRef<Path>) -> bool

Source§

fn fs_is_dir(&self, path: impl AsRef<Path>) -> Result<bool>

Source§

fn fs_is_dir_no_err(&self, path: impl AsRef<Path>) -> bool

Source§

fn fs_exists(&self, path: impl AsRef<Path>) -> Result<bool>

Source§

fn fs_exists_no_err(&self, path: impl AsRef<Path>) -> bool

Source§

impl<T> FsMetadataBoxed for T
where T: BaseFsMetadata + 'static,

Source§

impl<T> FsOpen for T
where T: BaseFsOpen,

Source§

fn fs_open( &self, path: impl AsRef<Path>, options: &OpenOptions, ) -> Result<Self::File>

Source§

impl<TFile, T> FsOpenBoxed for T
where TFile: FsFile + 'static, T: BaseFsOpen<File = TFile>,

Source§

fn fs_open_boxed( &self, path: &Path, open_options: &OpenOptions, ) -> Result<BoxedFsFile, Error>

Source§

impl<T> FsRead for T
where T: BaseFsRead,

Source§

fn fs_read(&self, path: impl AsRef<Path>) -> Result<Cow<'static, [u8]>>

Source§

fn fs_read_to_string(&self, path: impl AsRef<Path>) -> Result<Cow<'static, str>>

Source§

fn fs_read_to_string_lossy( &self, path: impl AsRef<Path>, ) -> Result<Cow<'static, str>>

Source§

impl<T> FsReadDir for T
where T: BaseFsReadDir,

Source§

fn fs_read_dir( &self, path: impl AsRef<Path>, ) -> Result<Box<dyn Iterator<Item = Result<Self::ReadDirEntry>>>>

Source§

impl<T> FsReadDirBoxed for T
where T: BaseFsReadDir,

Source§

impl<T> FsRemoveDir for T
where T: BaseFsRemoveDir,

Source§

fn fs_remove_dir(&self, path: impl AsRef<Path>) -> Result<()>

Source§

impl<T> FsRemoveDirAll for T

Source§

fn fs_remove_dir_all(&self, path: impl AsRef<Path>) -> Result<()>

Source§

impl<T> FsRemoveFile for T

Source§

fn fs_remove_file(&self, path: impl AsRef<Path>) -> Result<()>

Source§

impl<T> FsRename for T
where T: BaseFsRename,

Source§

fn fs_rename(&self, from: impl AsRef<Path>, to: impl AsRef<Path>) -> Result<()>

Source§

impl<T> FsSetFileTimes for T

Source§

fn fs_set_file_times( &self, path: impl AsRef<Path>, atime: SystemTime, mtime: SystemTime, ) -> Result<()>

Source§

impl<T> FsSetPermissions for T

Source§

fn fs_set_permissions(&self, path: impl AsRef<Path>, mode: u32) -> Result<()>

Source§

impl<T> FsSetSymlinkFileTimes for T

Source§

impl<T> FsSymlinkChown for T

Source§

impl<T> FsSymlinkDir for T

Source§

impl<T> FsSymlinkFile for T

Source§

impl<T> FsWrite for T
where T: BaseFsWrite,

Source§

fn fs_write(&self, path: impl AsRef<Path>, data: impl AsRef<[u8]>) -> Result<()>

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.