Struct FS

Source
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§

Source§

impl FS

Source

pub fn new() -> FS

Creates an empty FS with mode 0o777.

§Examples
let fs = FS::new();
Source

pub fn with_mode(mode: u32) -> FS

Creates an empty FS with the given mode.

§Examples
let fs = FS::with_mode(0o300);

Trait Implementations§

Source§

impl Clone for FS

Source§

fn clone(&self) -> FS

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 FS

Source§

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

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

impl Default for FS

Source§

fn default() -> Self

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

impl GenFS for FS

Source§

type DirBuilder = DirBuilder

The DirBuilder type in the same module implementing this trait.
Source§

type DirEntry = DirEntry

The DirEntry type in the same module implementing this trait.
Source§

type File = File

The File type in the same module implementing this trait.
Source§

type Metadata = Metadata

The Metadata type in the same module implementing this trait.
Source§

type OpenOptions = OpenOptions

The OpenOptions type in the same module implementing this trait.
Source§

type Permissions = Permissions

The Permissions type in the same module implementing this trait.
Source§

type ReadDir = ReadDir

The ReadDir type in the same module implementing this trait.
Source§

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>

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<()>

Creates a new, empty directory at the provided path. Read more
Source§

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
Creates a new hard link on the filesystem. Read more
Source§

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>

Returns an iterator over entries within a directory. Read more
Reads a symbolic link, returning the entry the link points to. Read more
Source§

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<()>

Removes a directory at path after removing all of its contents. Read more
Source§

fn remove_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

Removes a file from the filesystem. Read more
Source§

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

Renames a file or directory at from to to, replacing to if it exists. Read more
Source§

fn set_permissions<P: AsRef<Path>>( &self, path: P, perms: Self::Permissions, ) -> Result<()>

Changes the permissions of a file or directory. Read more
Query the metadata about a file without following symlinks. Read more
Source§

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

Returns a new DirBuilder for a directory for this filesystem. Read more
Source§

fn open_file<P: AsRef<Path>>(&self, path: P) -> Result<Self::File>

Opens a file in read-only mode. Read more
Source§

fn create_file<P: AsRef<Path>>(&self, path: P) -> Result<Self::File>

Opens a file in write-only mode. Read more
Source§

impl GenFSExt for FS

Creates a new symbolic link on the 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> 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.
Source§

impl<T> Erased for T