[−][src]Struct memofs::Vfs
A virtual filesystem with a configurable backend.
All operations on the Vfs take a lock on an internal backend. For performing
large batches of operations, it might be more performant to call lock()
and use VfsLock
instead.
Implementations
impl Vfs
[src]
pub fn new_default() -> Self
[src]
Creates a new Vfs
with the default backend, StdBackend
.
pub fn new<B: VfsBackend>(backend: B) -> Self
[src]
Creates a new Vfs
with the given backend.
pub fn lock(&self) -> VfsLock<'_>
[src]
Manually lock the Vfs, useful for large batches of operations.
pub fn set_watch_enabled(&self, enabled: bool)
[src]
Turns automatic file watching on or off. Enabled by default.
Turning off file watching may be useful for single-use cases, especially on platforms like macOS where registering file watches has significant performance cost.
pub fn read<P: AsRef<Path>>(&self, path: P) -> Result<Arc<Vec<u8>>>
[src]
Read a file from the VFS, or the underlying backend if it isn't resident.
Roughly equivalent to std::fs::read
.
pub fn write<P: AsRef<Path>, C: AsRef<[u8]>>(
&self,
path: P,
contents: C
) -> Result<()>
[src]
&self,
path: P,
contents: C
) -> Result<()>
Write a file to the VFS and the underlying backend.
Roughly equivalent to std::fs::write
.
pub fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>
[src]
Read all of the children of a directory.
Roughly equivalent to std::fs::read_dir
.
pub fn remove_file<P: AsRef<Path>>(&self, path: P) -> Result<()>
[src]
Remove a file.
Roughly equivalent to std::fs::remove_file
.
pub fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
[src]
Remove a directory and all of its descendants.
Roughly equivalent to std::fs::remove_dir_all
.
pub fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<Metadata>
[src]
Query metadata about the given path.
Roughly equivalent to std::fs::metadata
.
pub fn event_receiver(&self) -> Receiver<VfsEvent>
[src]
Retrieve a handle to the event receiver for this Vfs
.
pub fn commit_event(&self, event: &VfsEvent) -> Result<()>
[src]
Commit an event to this Vfs
.
Auto Trait Implementations
impl RefUnwindSafe for Vfs
impl Send for Vfs
impl Sync for Vfs
impl Unpin for Vfs
impl UnwindSafe for Vfs
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,