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.
SourceDirectoryNotADirectory
The base source directory path (i.e. the directory you want to copy from) exists, but does not point to a directory.
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
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.
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.
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_directory_rule: DestinationDirectoryRuleRequirements 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
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.
SourceSubPathEscapesSourceDirectory
An item inside the source directory somehow escaped outside the base source directory.
OtherIoError
An uncategorized unrecoverable IO error. See error for more information.