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

Source§

impl OsFileSystem

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl Clone for OsFileSystem

Source§

fn clone(&self) -> OsFileSystem

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 OsFileSystem

Source§

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

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

impl Default for OsFileSystem

Source§

fn default() -> OsFileSystem

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

impl FileSystem for OsFileSystem

Source§

type DirEntry = DirEntry

Source§

type ReadDir = ReadDir

Source§

fn current_dir(&self) -> Result<PathBuf>

Returns the current working directory. This is based on std::env::current_dir.
Source§

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

fn is_dir<P: AsRef<Path>>(&self, path: P) -> bool

Determines whether the path exists and points to a directory.
Source§

fn is_file<P: AsRef<Path>>(&self, path: P) -> bool

Determines whether the path exists and points to a file.
Source§

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

Creates a new directory. This is based on std::fs::create_dir.
Source§

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

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

Removes an empty directory. This is based on std::fs::remove_dir.
Source§

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

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

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

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

fn read_file<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>

Returns the contents of path. Read more
Source§

fn read_file_into<P, B>(&self, path: P, buf: B) -> Result<usize>
where P: AsRef<Path>, B: AsMut<Vec<u8>>,

Writes the contents of path into the buffer. If successful, returns the number of bytes that were read. Read more
Source§

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

Returns the contents of path as a string. Read more
Source§

fn create_file<P, B>(&self, path: P, buf: B) -> Result<()>
where P: AsRef<Path>, B: AsRef<[u8]>,

Writes buf to a new file at path. Read more
Source§

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

Removes the file at path. This is based on std::fs::remove_file.
Source§

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

Copies the file at path from to the path to. This is based on std::fs::copy.
Source§

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

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

Returns true if path is a readonly file. Read more
Source§

fn set_readonly<P: AsRef<Path>>(&self, path: P, readonly: bool) -> Result<()>

Sets or unsets the readonly flag of path. Read more
Source§

fn len<P: AsRef<Path>>(&self, path: P) -> u64

Returns the length of the node at the path or 0 if the node does not exist.
Source§

impl TempFileSystem for OsFileSystem

Source§

type TempDir = OsTempDir

Source§

fn temp_dir<S: AsRef<str>>(&self, prefix: S) -> Result<Self::TempDir>

Creates a new temporary directory.
Source§

impl UnixFileSystem for OsFileSystem

Source§

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

Returns the current mode bits of path. Read more
Source§

fn set_mode<P: AsRef<Path>>(&self, path: P, mode: u32) -> Result<()>

Sets the mode bits of path. Read more
Creates a new symbolic link on the filesystem. Read more
Gets the source for a symlink. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V