Struct filesystem::OsFileSystem
source · pub struct OsFileSystem {}
Expand description
An implementation of FileSystem
that interacts with the actual operating system’s file system.
This is primarily a wrapper for fs
methods.
Implementations
sourceimpl OsFileSystem
impl OsFileSystem
Trait Implementations
sourceimpl Clone for OsFileSystem
impl Clone for OsFileSystem
sourcefn clone(&self) -> OsFileSystem
fn clone(&self) -> OsFileSystem
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for OsFileSystem
impl Debug for OsFileSystem
sourceimpl Default for OsFileSystem
impl Default for OsFileSystem
sourcefn default() -> OsFileSystem
fn default() -> OsFileSystem
Returns the “default value” for a type. Read more
sourceimpl FileSystem for OsFileSystem
impl FileSystem for OsFileSystem
type DirEntry = DirEntry
type ReadDir = ReadDir
sourcefn current_dir(&self) -> Result<PathBuf>
fn current_dir(&self) -> Result<PathBuf>
Returns the current working directory.
This is based on
std::env::current_dir
. Read moresourcefn set_current_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn set_current_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Updates the current working directory.
This is based on
std::env::set_current_dir
. Read moresourcefn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool
Determines whether the path exists and points to a directory.
sourcefn is_file<P: AsRef<Path>>(&self, path: P) -> bool
fn is_file<P: AsRef<Path>>(&self, path: P) -> bool
Determines whether the path exists and points to a file.
sourcefn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn create_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Creates a new directory.
This is based on
std::fs::create_dir
. Read moresourcefn 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 any missing parents.
This is based on
std::fs::create_dir
. Read moresourcefn remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_dir<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes an empty directory.
This is based on
std::fs::remove_dir
. Read moresourcefn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
fn remove_dir_all<P: AsRef<Path>>(&self, path: P) -> Result<()>
Removes a directory and any child files or directories.
This is based on
std::fs::remove_dir_all
. Read moresourcefn 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 the entries in a directory.
This is based on
std::fs::read_dir
. Read moresourcefn write_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
fn write_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
Writes
buf
to a new or existing file at buf
.
This will overwrite any contents that already exist. Read moresourcefn overwrite_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
fn overwrite_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
Writes
buf
to an existing file at buf
.
This will overwrite any contents that already exist. Read moresourcefn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>
Returns the contents of
path
. Read moresourcefn read_file_to_string<P: AsRef<Path>>(&self, path: P) -> Result<String>
fn read_file_to_string<P: AsRef<Path>>(&self, path: P) -> Result<String>
Returns the contents of
path
as a string. Read moresourcefn create_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
fn create_file<P, B>(&self, path: P, buf: B) -> Result<()>where
P: AsRef<Path>,
B: AsRef<[u8]>,
sourcefn rename<P, Q>(&self, from: P, to: Q) -> Result<()>where
P: AsRef<Path>,
Q: AsRef<Path>,
fn rename<P, Q>(&self, from: P, to: Q) -> Result<()>where
P: AsRef<Path>,
Q: AsRef<Path>,
Renames a file or directory.
If both
from
and to
are files, to
will be replaced.
Based on std::fs::rename
. Read moresourceimpl TempFileSystem for OsFileSystem
impl TempFileSystem for OsFileSystem
Auto Trait Implementations
impl RefUnwindSafe for OsFileSystem
impl Send for OsFileSystem
impl Sync for OsFileSystem
impl Unpin for OsFileSystem
impl UnwindSafe for OsFileSystem
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more