Trait genfs::Fs [] [src]

pub trait Fs {
    type Path: ?Sized;
    type PathOwned;
    type File: File<Error = Self::Error>;
    type Dir: Dir<Self::DirEntry, Self::Error>;
    type DirEntry: DirEntry<Path = Self::Path, Metadata = Self::Metadata, Error = Self::Error>;
    type Metadata;
    type Permissions;
    type Error;
    fn open(
        &self,
        path: &Self::Path,
        options: &OpenOptions<Self::Permissions>
    ) -> Result<Self::File, Self::Error>;
fn remove_file(&mut self, path: &Self::Path) -> Result<(), Self::Error>;
fn metadata(&self, path: &Self::Path) -> Result<Self::Metadata, Self::Error>;
fn symlink_metadata(
        &self,
        path: &Self::Path
    ) -> Result<Self::Metadata, Self::Error>;
fn rename(
        &mut self,
        from: &Self::Path,
        to: &Self::Path
    ) -> Result<(), Self::Error>;
fn copy(
        &mut self,
        from: &Self::Path,
        to: &Self::Path
    ) -> Result<u64, Self::Error>;
fn hard_link(
        &mut self,
        src: &Self::Path,
        dst: &Self::Path
    ) -> Result<(), Self::Error>;
fn symlink(
        &mut self,
        src: &Self::Path,
        dst: &Self::Path
    ) -> Result<(), Self::Error>;
fn read_link(
        &self,
        path: &Self::Path
    ) -> Result<Self::PathOwned, Self::Error>;
fn canonicalize(
        &self,
        path: &Self::Path
    ) -> Result<Self::PathOwned, Self::Error>;
fn create_dir(
        &mut self,
        path: &Self::Path,
        options: &DirOptions<Self::Permissions>
    ) -> Result<(), Self::Error>;
fn remove_dir(&mut self, path: &Self::Path) -> Result<(), Self::Error>;
fn remove_dir_all(&mut self, path: &Self::Path) -> Result<(), Self::Error>;
fn read_dir(&self, path: &Self::Path) -> Result<Self::Dir, Self::Error>;
fn set_permissions(
        &mut self,
        path: &Self::Path,
        perm: Self::Permissions
    ) -> Result<(), Self::Error>; }

Filesystem manipulation operations.

This trait contains basic methods to manipulate the contents of the local filesystem. All methods in this module represent cross-platform filesystem operations.

Associated Types

The borrowed path slice that represents a relative or absolute path on the filesystem.

The owned path that represents a relative or absolute path on the filesystem.

The type that represents a file on the filesystem.

The type that represents a directory on the filesystem.

The type that represents an entry in a directory on the filesystem.

The type that represents the metadata on the filesystem.

The type that represents the permissions of a reader/writer on the filesystem.

The type that represents the set of all errors that can occur during reading or writing.

Required Methods

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

Errors

This function will return an error under a number of different circumstances.

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).

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • path points to a directory.
  • The user lacks permissions to remove the file.

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.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The user lacks permissions to perform metadata call on path.
  • path does not exist.

Query the metadata about a file without following symlinks.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The user lacks permissions to perform metadata call on path.
  • path does not exist.

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.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • from does not exist.
  • The user lacks permissions to view contents.
  • from and to are on separate filesystems.

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

This function will overwrite the contents of to.

Note that if from and to both point to the same file, then the file will likely get truncated by this operation.

On success, the total number of bytes copied is returned and it is equal to the length of the to file as reported by metadata.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The from path is not a file.
  • The from file does not exist.
  • The current process does not have the permission rights to access from or write to.

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.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The src path is not a file or doesn't exist.

Creates a new symbolic link on the filesystem.

The dst path will be a symbolic link pointing to the src path.

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

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • path is not a symbolic link.
  • path does not exist.

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

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • path does not exist.
  • A component in path is not a directory.

Creates a new, empty directory at the provided path with the specified options.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • User lacks permissions to create directory at path.
  • path already exists, unless the recursive options was set.

Removes an existing, empty directory.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The user lacks permissions to remove the directory at the provided path. * The directory isn't empty.

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.

Errors

See Fs::remove_file and Fs::remove_dir.

Returns an iterator over the entries within a directory.

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

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • The provided path doesn't exist.
  • The process lacks permissions to view the contents.
  • The path points at a non-directory file.

Changes the permissions found on a file or a directory.

Errors

This function will return an error in the following situations, but is not limited to just these cases:

  • path does not exist.
  • The user lacks the permission to change attributes of the file.

Implementors