pub struct FS(/* private fields */);
Expand description
An in-memory struct that satisfies rsfs::GenFS
.
FS
is thread safe and copyable. It operates internally with an Arc<Mutex<FileSystem>>
(FileSystem
not being exported) and forces all filesystem calls to go through the mutex. FS
attempts to mimic all real errors that could occur on a filesystem. Generally, unless a FS
is
setup with restrictive permissions, errors will only be encountered when operating on
non-existent filesystem entries or performing invalid oprations.
See the module documentation or every struct’s documentation for more examples of using an
FS
.
§Examples
use rsfs::*;
use rsfs::mem::FS;
let fs = FS::new();
Implementations§
Trait Implementations§
Source§impl GenFS for FS
impl GenFS for FS
Source§type DirBuilder = DirBuilder
type DirBuilder = DirBuilder
The
DirBuilder
type in the same module implementing this trait.Source§type OpenOptions = OpenOptions
type OpenOptions = OpenOptions
The
OpenOptions
type in the same module implementing this trait.Source§type Permissions = Permissions
type Permissions = Permissions
The
Permissions
type in the same module implementing this trait.Source§fn canonicalize<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
fn canonicalize<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
Returns the canonical form of a path with all intermediate components normalized and
symbolic links resolved. Read more
Source§fn copy<P: AsRef<Path>, Q: AsRef<Path>>(&self, from: P, to: Q) -> Result<u64>
fn copy<P: AsRef<Path>, Q: AsRef<Path>>(&self, from: P, to: Q) -> Result<u64>
Copies the contents of one file to another. This function will also copy the permission bits
of the original file to the destination file. Read more
Source§fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Creates a new, empty directory at the provided path. Read more
Source§fn create_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn create_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
Recursively creates a directory and all its parent components if they are missing. Read more
Source§fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(
&self,
src: P,
dst: Q,
) -> Result<()>
fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>( &self, src: P, dst: Q, ) -> Result<()>
Creates a new hard link on the filesystem. Read more
Source§fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<Self::Metadata>
fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<Self::Metadata>
Returns metadata information of the file or directory at path. Read more
Source§fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<Self::ReadDir>
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<Self::ReadDir>
Returns an iterator over entries within a directory. Read more
Source§fn read_link<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
fn read_link<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>
Reads a symbolic link, returning the entry the link points to. Read more
Source§fn remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes an existing, empty directory. Read more
Source§fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes a directory at path after removing all of its contents. Read more
Source§fn remove_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes a file from the filesystem. Read more
Source§fn set_permissions<P: AsRef<Path>>(
&self,
path: P,
perms: Self::Permissions,
) -> Result<()>
fn set_permissions<P: AsRef<Path>>( &self, path: P, perms: Self::Permissions, ) -> Result<()>
Changes the permissions of a file or directory. Read more
Source§fn symlink_metadata<P: AsRef<Path>>(&self, path: P) -> Result<Self::Metadata>
fn symlink_metadata<P: AsRef<Path>>(&self, path: P) -> Result<Self::Metadata>
Query the metadata about a file without following symlinks. Read more
Source§fn new_openopts(&self) -> Self::OpenOptions
fn new_openopts(&self) -> Self::OpenOptions
Returns a new OpenOptions for a file for this filesytem. Read more
Source§fn new_dirbuilder(&self) -> Self::DirBuilder
fn new_dirbuilder(&self) -> Self::DirBuilder
Returns a new DirBuilder for a directory for this filesystem. Read more
Auto Trait Implementations§
impl Freeze for FS
impl !RefUnwindSafe for FS
impl Send for FS
impl Sync for FS
impl Unpin for FS
impl !UnwindSafe for FS
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