pub struct VfsPath { /* private fields */ }
Expand description
A virtual filesystem path, identifying a single file or directory in this virtual filesystem
Implementations
sourceimpl VfsPath
impl VfsPath
sourcepub fn new<T: FileSystem>(filesystem: T) -> Self
pub fn new<T: FileSystem>(filesystem: T) -> Self
Creates a root path for the given filesystem
sourcepub fn join(&self, path: impl AsRef<str>) -> VfsResult<Self>
pub fn join(&self, path: impl AsRef<str>) -> VfsResult<Self>
Appends a path segment to this path, returning the result
sourcepub fn read_dir(&self) -> VfsResult<Box<dyn Iterator<Item = VfsPath>>>
pub fn read_dir(&self) -> VfsResult<Box<dyn Iterator<Item = VfsPath>>>
Iterates over all entries of this directory path
sourcepub fn create_dir(&self) -> VfsResult<()>
pub fn create_dir(&self) -> VfsResult<()>
Creates the directory at this path
Note that the parent directory must exist.
sourcepub fn create_dir_all(&self) -> VfsResult<()>
pub fn create_dir_all(&self) -> VfsResult<()>
Creates the directory at this path, also creating parent directories as necessary
sourcepub fn open_file(&self) -> VfsResult<Box<dyn SeekAndRead>>
pub fn open_file(&self) -> VfsResult<Box<dyn SeekAndRead>>
Opens the file at this path for reading
sourcepub fn create_file(&self) -> VfsResult<Box<dyn Write>>
pub fn create_file(&self) -> VfsResult<Box<dyn Write>>
Creates a file at this path for writing, overwriting any existing file
sourcepub fn append_file(&self) -> VfsResult<Box<dyn Write>>
pub fn append_file(&self) -> VfsResult<Box<dyn Write>>
Opens the file at this path for appending
sourcepub fn remove_file(&self) -> VfsResult<()>
pub fn remove_file(&self) -> VfsResult<()>
Removes the file at this path
sourcepub fn remove_dir(&self) -> VfsResult<()>
pub fn remove_dir(&self) -> VfsResult<()>
Removes the directory at this path
The directory must be empty.
sourcepub fn remove_dir_all(&self) -> VfsResult<()>
pub fn remove_dir_all(&self) -> VfsResult<()>
Ensures that the directory at this path is removed, recursively deleting all contents if necessary
Returns successfully if directory does not exist
sourcepub fn metadata(&self) -> VfsResult<VfsMetadata>
pub fn metadata(&self) -> VfsResult<VfsMetadata>
Returns the file metadata for the file at this path
sourcepub fn exists(&self) -> VfsResult<bool>
pub fn exists(&self) -> VfsResult<bool>
Returns true if a file or directory exists at this path, false otherwise
sourcepub fn parent(&self) -> Option<Self>
pub fn parent(&self) -> Option<Self>
Returns the parent path of this portion of this path
Returns None
if this is a root path
sourcepub fn walk_dir(&self) -> VfsResult<WalkDirIterator>
pub fn walk_dir(&self) -> VfsResult<WalkDirIterator>
Recursively iterates over all the directories and files at this path
Directories are visited before their children
Note that the iterator items can contain errors, usually when directories are removed during the iteration. The returned paths may also point to non-existant files if there is concurrent removal.
Also note that loops in the file system hierarchy may cause this iterator to never terminate.
sourcepub fn read_to_string(&self) -> VfsResult<String>
pub fn read_to_string(&self) -> VfsResult<String>
Reads a complete file to a string
Returns an error if the file does not exist or is not valid UTF-8
sourcepub fn copy_file(&self, destination: &VfsPath) -> VfsResult<()>
pub fn copy_file(&self, destination: &VfsPath) -> VfsResult<()>
Copies a file to a new destination
The destination must not exist, but its parent directory must
sourcepub fn move_file(&self, destination: &VfsPath) -> VfsResult<()>
pub fn move_file(&self, destination: &VfsPath) -> VfsResult<()>
Moves or renames a file to a new destination
The destination must not exist, but its parent directory must
sourcepub fn copy_dir(&self, destination: &VfsPath) -> VfsResult<u64>
pub fn copy_dir(&self, destination: &VfsPath) -> VfsResult<u64>
Copies a directory to a new destination, recursively
The destination must not exist, but the parent directory must
Returns the number of files copied
sourcepub fn is_file(&self) -> VfsResult<bool>
pub fn is_file(&self) -> VfsResult<bool>
Returns true
if the path exists and is pointing at a regular file, otherwise returns false
.
Note that this call may fail if the file’s existence cannot be determined or the metadata can not be retrieved
Trait Implementations
sourceimpl<T: FileSystem> From<T> for VfsPath
impl<T: FileSystem> From<T> for VfsPath
impl Eq for VfsPath
Auto Trait Implementations
impl !RefUnwindSafe for VfsPath
impl Send for VfsPath
impl Sync for VfsPath
impl Unpin for VfsPath
impl !UnwindSafe for VfsPath
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more