Trait io_providers::fs::Fs[][src]

pub trait Fs {
    fn open<P: AsRef<Path>>(
        &mut self,
        path: P,
        open_options: &OpenOptions
    ) -> Result<File>;
fn canonicalize<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>;
fn copy<P: AsRef<Path>, Q: AsRef<Path>>(
        &mut self,
        from: P,
        to: Q
    ) -> Result<u64>;
fn create_dir<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
fn create_dir_all<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
fn hard_link<P: AsRef<Path>, Q: AsRef<Path>>(
        &mut self,
        src: P,
        dst: Q
    ) -> Result<()>;
fn metadata<P: AsRef<Path>>(&self, path: P) -> Result<Metadata>;
fn read<P: AsRef<Path>>(&self, path: P) -> Result<Vec<u8>>;
fn read_dir<P: AsRef<Path>>(&self, path: P) -> Result<ReadDir>;
fn read_link<P: AsRef<Path>>(&self, path: P) -> Result<PathBuf>;
fn read_to_string<P: AsRef<Path>>(&self, path: P) -> Result<String>;
fn remove_dir<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
fn remove_dir_all<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
fn remove_file<P: AsRef<Path>>(&mut self, path: P) -> Result<()>;
fn rename<P: AsRef<Path>, Q: AsRef<Path>>(
        &mut self,
        from: P,
        to: Q
    ) -> Result<()>;
fn set_permissions<P: AsRef<Path>>(
        &mut self,
        path: P,
        perm: Permissions
    ) -> Result<()>;
fn symlink_metadata<P: AsRef<Path>>(&self, path: P) -> Result<Metadata>;
fn write<P: AsRef<Path>, C: AsRef<[u8]>>(
        &mut self,
        path: P,
        contents: C
    ) -> Result<()>;
fn exists<P: AsRef<Path>>(&self, path: P) -> bool; }

Provides access to file I/O.

Required Methods

Opens a file at path with the options specified by open_options.

See std::fs::OpenOptions for more information.

Returns the canonical, absolute form of a path with all intermediate components normalized and symbolic links resolved.

See std::fs::canonicalize for more information.

Copies the contents of one file to another. This function will also copy the permission bits of the original file to the destination file.

See std::fs::copy for more information.

Creates a new, empty directory at the provided path.

See std::fs::create_dir for more information.

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

See std::fs::create_dir_all for more information.

Creates a new hard link on the filesystem.

The dst path will be a link pointing to the src path. Note that systems often require these two paths to both be located on the same filesystem.

See std::fs::hard_link for more information.

Given a path, query the file system to get information about a file, directory, etc.

This function will traverse symbolic links to query information about the destination file.

See std::fs::metadata for more information.

Read the entire contents of a file into a bytes vector.

This is a convenience function for using fs::File::open and fs::read_to_end with fewer imports and without an intermediate variable. It pre-allocates a buffer based on the file size when available, so it is generally faster than reading into a vector created with Vec::new().

See std::fs::read for more information.

Returns an iterator over the entries within a directory.

The iterator will yield instances of io::Result<fs::DirEntry]>. New errors may be encountered after an iterator is initially constructed.

See std::fs::read_dir for more information.

Reads a symbolic link, returning the file that the link points to.

See std::fs::read_link for more information.

Read the entire contents of a file into a string.

This is a convenience function for using fs::File::open and fs::read_to_string with fewer imports and without an intermediate variable. It pre-allocates a buffer based on the file size when available, so it is generally faster than reading into a string created with String::new().

See std::fs::read_to_string for more information.

Removes an existing, empty directory.

See std::fs::remove_dir for more information.

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

This function does not follow symbolic links and it will simply remove the symbolic link itself.

See std::fs::remove_dir_all for more information.

Removes a file from the filesystem.

Note that there is no guarantee that the file is immediately deleted (e.g. depending on platform, other open file descriptors may prevent immediate removal).

See std::fs::remove_file for more information.

Rename a file or directory to a new name, replacing the original file if to already exists.

This will not work if the new name is on a different mount point.

See std::fs::rename for more information.

Changes the permissions found on a file or a directory.

See std::fs::set_permissions for more information.

Query the metadata about a file without following symlinks.

See std::fs::symlink_metadata for more information.

Write a slice as the entire contents of a file.

This function will create a file if it does not exist, and will entirely replace its contents if it does.

This is a convenience function for using fs::File::create and fs::write_all with fewer imports.

See std::fs::write for more information.

Returns whether the path points at an existing entity.

This function will traverse symbolic links to query information about the destination file. In case of broken symbolic links this will return false.

If you cannot access the directory containing the file, e.g. because of a permission error, this will return false.

See std::path::Path.exists for more information.

Implementors