Enum DirectoryError

Source
pub enum DirectoryError {
    SourceDirectoryNotFound {
        directory_path: PathBuf,
    },
    SourceDirectoryNotADirectory {
        directory_path: PathBuf,
    },
    UnableToAccessSource {
        path: PathBuf,
        error: Error,
    },
    SourceEntryNoLongerExists {
        path: PathBuf,
    },
    InvalidDestinationDirectoryPath {
        path: PathBuf,
    },
    DestinationDirectoryNotEmpty {
        destination_path: PathBuf,
        destination_directory_rule: DestinationDirectoryRule,
    },
    UnableToAccessDestination {
        path: PathBuf,
        error: Error,
    },
    DestinationItemAlreadyExists {
        path: PathBuf,
    },
    SourceSubPathEscapesSourceDirectory {
        path: PathBuf,
    },
    OtherIoError {
        error: Error,
    },
}
Expand description

An error that can occur when copying or moving a directory.

Variants§

§

SourceDirectoryNotFound

The base source directory (i.e. the directory you want to copy from) does not exist.

Fields

§directory_path: PathBuf

Source directory path.

§

SourceDirectoryNotADirectory

The base source directory path (i.e. the directory you want to copy from) exists, but does not point to a directory.

Fields

§directory_path: PathBuf

Source directory path.

§

UnableToAccessSource

A base source directory, its sub-directory or a file inside it cannot be read.

For example, this can happen due to missing permissions, files or directories being removed externally mid-copy or mid-move, etc.

The inner std::io::Error will likely describe a more precise cause of this error.

Fields

§path: PathBuf

The path we are unable to access.

§error: Error

IO error describing why the source directory could not be accessed.

§

SourceEntryNoLongerExists

A base source directory, its sub-directory or a file inside it no longer exists (since being first scanned when preparing for a copy, move etc.).

This is basically a TOCTOU race condition.

Fields

§path: PathBuf

The path to a directory or file that is invalid.

§

InvalidDestinationDirectoryPath

The provided destination directory path points to an invalid location.

This can occur due to (not an exhaustive list):

  • source and destination directory are the same,
  • destination directory is a subdirectory of the source directory, or,
  • destination path already exists, but is not a directory.

Fields

§path: PathBuf

Invalid destination path.

§

DestinationDirectoryNotEmpty

The file system state of the destination directory does not match the provided DestinationDirectoryRule.

For example, this happens when the the destination directory rule is set to DestinationDirectoryRule::AllowEmpty, but the destination directory isn’t actually empty.

Fields

§destination_path: PathBuf

Destination directory path.

§destination_directory_rule: DestinationDirectoryRule

Requirements for the destination directory (e.g. it should be empty or it should not exist at all).

§

UnableToAccessDestination

A destination directory or a file inside it cannot be created or written to (e.g. due to missing permissions).

The inner std::io::Error will likely describe a more precise cause of this error.

Fields

§path: PathBuf

Path that cannot be accessed.

§error: Error

IO error describing why the target directory could not be accessed.

§

DestinationItemAlreadyExists

A destination directory or a file inside it already exists.

This can also happen when we intended to copy a file to the destination, but a directory with the same name appeared mid-copy (an unavoidable time-of-check time-of-use bug).

The path field contains the path that already existed, causing this error.

Fields

§path: PathBuf

Path of the target directory or file that already exists.

§

SourceSubPathEscapesSourceDirectory

An item inside the source directory somehow escaped outside the base source directory.

Fields

§path: PathBuf

The related path that “escaped” the source directory.

§

OtherIoError

An uncategorized unrecoverable IO error. See error for more information.

Fields

§error: Error

IO error describing the cause of the outer error.

Trait Implementations§

Source§

impl Debug for DirectoryError

Source§

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

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

impl Display for DirectoryError

Source§

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

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

impl Error for DirectoryError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.