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
impl InMemorySys
pub fn new_with_cwd(cwd: impl AsRef<Path>) -> Self
pub fn set_seed(&self, seed: Option<u64>)
pub fn set_time(&self, time: Option<SystemTime>)
Sourcepub fn disable_thread_sleep(&self)
pub fn disable_thread_sleep(&self)
Makes thread sleeping a no-op.
pub fn fs_insert(&self, path: impl AsRef<Path>, data: impl AsRef<[u8]>)
Sourcepub fn fs_insert_json(&self, path: impl AsRef<Path>, json: Value)
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
impl BaseFsMetadata for InMemorySys
type Metadata = InMemoryMetadata
Source§impl BaseFsOpen for InMemorySys
impl BaseFsOpen for InMemorySys
type File = InMemoryFile
Source§impl BaseFsReadDir for InMemorySys
impl BaseFsReadDir for InMemorySys
Source§impl Clone for InMemorySys
impl Clone for InMemorySys
Source§fn clone(&self) -> InMemorySys
fn clone(&self) -> InMemorySys
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for InMemorySys
impl Debug for InMemorySys
Source§impl Default for InMemorySys
impl Default for InMemorySys
Source§impl EnvCacheDir for InMemorySys
impl EnvCacheDir for InMemorySys
fn env_cache_dir(&self) -> Option<PathBuf>
Source§impl EnvCurrentDir for InMemorySys
impl EnvCurrentDir for InMemorySys
fn env_current_dir(&self) -> Result<PathBuf>
Source§impl EnvHomeDir for InMemorySys
impl EnvHomeDir for InMemorySys
fn env_home_dir(&self) -> Option<PathBuf>
Source§impl EnvSetUmask for InMemorySys
impl EnvSetUmask for InMemorySys
Source§impl EnvTempDir for InMemorySys
impl EnvTempDir for InMemorySys
fn env_temp_dir(&self) -> Result<PathBuf>
Source§impl EnvVars for InMemorySys
impl EnvVars for InMemorySys
Source§impl ProcessExit for InMemorySys
impl ProcessExit for InMemorySys
fn process_exit(&self, code: i32) -> !
Source§impl SystemRandom for InMemorySys
impl SystemRandom for InMemorySys
Source§impl SystemTimeNow for InMemorySys
impl SystemTimeNow for InMemorySys
fn sys_time_now(&self) -> SystemTime
Source§impl ThreadSleep for InMemorySys
impl ThreadSleep for InMemorySys
fn thread_sleep(&self, dur: Duration)
impl BaseEnvRemoveVar for InMemorySys
impl BaseEnvSetCurrentDir for InMemorySys
impl BaseEnvSetVar for InMemorySys
impl BaseEnvVar for InMemorySys
impl BaseFsCanonicalize for InMemorySys
impl BaseFsChown for InMemorySys
impl BaseFsCloneFile for InMemorySys
impl BaseFsCopy for InMemorySys
impl BaseFsCreateDir for InMemorySys
impl BaseFsCreateJunction for InMemorySys
impl BaseFsHardLink for InMemorySys
impl BaseFsRead for InMemorySys
impl BaseFsReadLink for InMemorySys
impl BaseFsRemoveDir for InMemorySys
impl BaseFsRemoveDirAll for InMemorySys
impl BaseFsRemoveFile for InMemorySys
impl BaseFsRename for InMemorySys
impl BaseFsSetFileTimes for InMemorySys
impl BaseFsSetPermissions for InMemorySys
impl BaseFsSetSymlinkFileTimes for InMemorySys
impl BaseFsSymlinkChown for InMemorySys
impl BaseFsSymlinkDir for InMemorySys
impl BaseFsSymlinkFile for InMemorySys
impl BaseFsWrite for InMemorySys
Auto Trait Implementations§
impl Freeze for InMemorySys
impl !RefUnwindSafe for InMemorySys
impl Send for InMemorySys
impl Sync for InMemorySys
impl Unpin for InMemorySys
impl UnsafeUnpin for InMemorySys
impl !UnwindSafe for InMemorySys
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> EnvRemoveVar for Twhere
T: BaseEnvRemoveVar,
impl<T> EnvRemoveVar for Twhere
T: BaseEnvRemoveVar,
fn env_remove_var(&self, key: impl AsRef<OsStr>)
Source§impl<T> EnvSetCurrentDir for Twhere
T: BaseEnvSetCurrentDir,
impl<T> EnvSetCurrentDir for Twhere
T: BaseEnvSetCurrentDir,
Source§impl<T> EnvSetVar for Twhere
T: BaseEnvSetVar,
impl<T> EnvSetVar for Twhere
T: BaseEnvSetVar,
Source§impl<T> EnvVar for Twhere
T: BaseEnvVar,
impl<T> EnvVar for Twhere
T: BaseEnvVar,
Source§impl<T> EnvVarsBoxed for T
impl<T> EnvVarsBoxed for T
Source§impl<T> FsCanonicalize for Twhere
T: BaseFsCanonicalize,
impl<T> FsCanonicalize for Twhere
T: BaseFsCanonicalize,
Source§impl<T> FsChown for Twhere
T: BaseFsChown,
impl<T> FsChown for Twhere
T: BaseFsChown,
Source§impl<T> FsCloneFile for Twhere
T: BaseFsCloneFile,
impl<T> FsCloneFile for Twhere
T: BaseFsCloneFile,
Source§impl<T> FsCopy for Twhere
T: BaseFsCopy,
impl<T> FsCopy for Twhere
T: BaseFsCopy,
Source§impl<T> FsCreateDir for Twhere
T: BaseFsCreateDir,
impl<T> FsCreateDir for Twhere
T: BaseFsCreateDir,
fn fs_create_dir( &self, path: impl AsRef<Path>, options: &CreateDirOptions, ) -> Result<()>
Source§impl<T> FsCreateDirAll for Twhere
T: BaseFsCreateDir,
impl<T> FsCreateDirAll for Twhere
T: BaseFsCreateDir,
Source§impl<T> FsCreateJunction for Twhere
T: BaseFsCreateJunction,
impl<T> FsCreateJunction for Twhere
T: BaseFsCreateJunction,
Source§impl<T> FsHardLink for Twhere
T: BaseFsHardLink,
impl<T> FsHardLink for Twhere
T: BaseFsHardLink,
Source§impl<T> FsMetadata for Twhere
T: BaseFsMetadata,
impl<T> FsMetadata for Twhere
T: BaseFsMetadata,
fn fs_metadata(&self, path: impl AsRef<Path>) -> Result<Self::Metadata>
fn fs_symlink_metadata(&self, path: impl AsRef<Path>) -> Result<Self::Metadata>
fn fs_is_file(&self, path: impl AsRef<Path>) -> Result<bool>
fn fs_is_file_no_err(&self, path: impl AsRef<Path>) -> bool
fn fs_is_dir(&self, path: impl AsRef<Path>) -> Result<bool>
fn fs_is_dir_no_err(&self, path: impl AsRef<Path>) -> bool
fn fs_exists(&self, path: impl AsRef<Path>) -> Result<bool>
fn fs_exists_no_err(&self, path: impl AsRef<Path>) -> bool
fn fs_is_symlink(&self, path: impl AsRef<Path>) -> Result<bool>
fn fs_is_symlink_no_err(&self, path: impl AsRef<Path>) -> bool
Source§impl<T> FsMetadataBoxed for Twhere
T: BaseFsMetadata + 'static,
impl<T> FsMetadataBoxed for Twhere
T: BaseFsMetadata + 'static,
fn fs_metadata_boxed(&self, path: &Path) -> Result<BoxedFsMetadataValue, Error>
fn fs_symlink_metadata_boxed( &self, path: &Path, ) -> Result<BoxedFsMetadataValue, Error>
Source§impl<T> FsOpen for Twhere
T: BaseFsOpen,
impl<T> FsOpen for Twhere
T: BaseFsOpen,
Source§impl<TFile, T> FsOpenBoxed for Twhere
TFile: FsFile + 'static,
T: BaseFsOpen<File = TFile>,
impl<TFile, T> FsOpenBoxed for Twhere
TFile: FsFile + 'static,
T: BaseFsOpen<File = TFile>,
fn fs_open_boxed( &self, path: &Path, open_options: &OpenOptions, ) -> Result<BoxedFsFile, Error>
Source§impl<T> FsRead for Twhere
T: BaseFsRead,
impl<T> FsRead for Twhere
T: BaseFsRead,
Source§impl<T> FsReadDir for Twhere
T: BaseFsReadDir,
impl<T> FsReadDir for Twhere
T: BaseFsReadDir,
fn fs_read_dir( &self, path: impl AsRef<Path>, ) -> Result<Box<dyn Iterator<Item = Result<Self::ReadDirEntry>>>>
Source§impl<T> FsReadDirBoxed for Twhere
T: BaseFsReadDir,
impl<T> FsReadDirBoxed for Twhere
T: BaseFsReadDir,
Source§impl<T> FsReadLink for Twhere
T: BaseFsReadLink,
impl<T> FsReadLink for Twhere
T: BaseFsReadLink,
Source§impl<T> FsRemoveDir for Twhere
T: BaseFsRemoveDir,
impl<T> FsRemoveDir for Twhere
T: BaseFsRemoveDir,
Source§impl<T> FsRemoveDirAll for Twhere
T: BaseFsRemoveDirAll,
impl<T> FsRemoveDirAll for Twhere
T: BaseFsRemoveDirAll,
Source§impl<T> FsRemoveFile for Twhere
T: BaseFsRemoveFile,
impl<T> FsRemoveFile for Twhere
T: BaseFsRemoveFile,
Source§impl<T> FsRename for Twhere
T: BaseFsRename,
impl<T> FsRename for Twhere
T: BaseFsRename,
Source§impl<T> FsSetFileTimes for Twhere
T: BaseFsSetFileTimes,
impl<T> FsSetFileTimes for Twhere
T: BaseFsSetFileTimes,
fn fs_set_file_times( &self, path: impl AsRef<Path>, atime: SystemTime, mtime: SystemTime, ) -> Result<()>
Source§impl<T> FsSetPermissions for Twhere
T: BaseFsSetPermissions,
impl<T> FsSetPermissions for Twhere
T: BaseFsSetPermissions,
Source§impl<T> FsSetSymlinkFileTimes for Twhere
T: BaseFsSetSymlinkFileTimes,
impl<T> FsSetSymlinkFileTimes for Twhere
T: BaseFsSetSymlinkFileTimes,
fn fs_set_symlink_file_times( &self, path: impl AsRef<Path>, atime: SystemTime, mtime: SystemTime, ) -> Result<()>
Source§impl<T> FsSymlinkChown for Twhere
T: BaseFsSymlinkChown,
impl<T> FsSymlinkChown for Twhere
T: BaseFsSymlinkChown,
Source§impl<T> FsSymlinkDir for Twhere
T: BaseFsSymlinkDir,
impl<T> FsSymlinkDir for Twhere
T: BaseFsSymlinkDir,
Source§impl<T> FsSymlinkFile for Twhere
T: BaseFsSymlinkFile,
impl<T> FsSymlinkFile for Twhere
T: BaseFsSymlinkFile,
Source§impl<T> FsWrite for Twhere
T: BaseFsWrite,
impl<T> FsWrite for Twhere
T: BaseFsWrite,
Source§impl<T> PathsInErrorsExt for Twhere
T: ?Sized,
impl<T> PathsInErrorsExt for Twhere
T: ?Sized,
Source§fn with_paths_in_errors(&self) -> SysWithPathsInErrors<'_, Self>
fn with_paths_in_errors(&self) -> SysWithPathsInErrors<'_, Self>
Wraps
self in a SysWithPathsInErrors that includes paths in error messages.