Struct VirtualFileSystem

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

A reference to an virtual file system.

Implementations§

Source§

impl VirtualFileSystem

Source

pub fn try_new<P>(root: P) -> Result<VirtualFileSystem, Error>
where P: AsRef<Path>,

Creates new VirtualFileSystem.

root - base directory for VFS. A root path must exists; else return value will be io::Error. It will be normalized.

Source

pub fn root(&self) -> PathBuf

Returns a root path.

Source

pub fn absolute<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

Convert relative path to absolute.

If path is absolute and starts with current root, then return it, else return None. If path is relative, then append it to the end of the current root and return joined path.

Source

pub fn relative<P>(&self, path: P) -> Option<PathBuf>
where P: AsRef<Path>,

Convert absolute path to relative.

If path is relative, then normalize it and return. If path is equal to root, then return . (current). If root equals to /foo/bar and path equals to /foo/bar/more, then return more.

Source

pub fn exists<P>(&self, path: P) -> bool
where P: AsRef<Path>,

Returns true if the path points at an existing entity.

Source

pub fn chroot<P>(&mut self, new_root: P) -> bool
where P: AsRef<Path>,

Change current root.

A new_root path may be absolute or relative. Return true if root was change.

Source

pub fn create_dir<P>(&self, path: P) -> Result<(), Error>
where P: AsRef<Path>,

Creates a new, empty directory at the provided path.

Source

pub fn create_dir_all<P>(&self, path: P) -> Result<(), Error>
where P: AsRef<Path>,

Recursively create a directory and all of its parent components if they are missing.

Source

pub fn remove_dir<P>(&self, path: P) -> Result<(), Error>
where P: AsRef<Path>,

Removes an existing, empty directory.

Source

pub fn remove_dir_all<P>(&self, path: P) -> Result<(), Error>
where P: AsRef<Path>,

Removes a directory at this path, after removing all its contents. Use carefully!

Source

pub fn visit_all(&self, cb: &dyn Fn(&DirEntry)) -> Result<(), Error>

Recursively traverses the contents of the directory and calls a callback for each item.

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> 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, 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.