Skip to main content

PathError

Enum PathError 

Source
#[non_exhaustive]
pub enum PathError {
Show 17 variants EmptyInput, EmbeddedNul, UndefinedEnvironmentVariable { name: String, }, MalformedEnvironmentVariable { input: String, }, HomeDirectoryUnavailable, CurrentDirectoryUnavailable { source: Error, }, DriveRelativePath { path: String, }, AbsoluteChildPath { path: String, }, RootEscape { path: String, }, NotUtf8, InvalidPath { message: String, }, Filesystem { path: String, source: Error, }, Traversal { message: String, }, InvalidGlob { message: String, }, Cache { message: String, }, InvalidAppName { message: String, }, ExpansionDepthExceeded { max_depth: u32, },
}
Expand description

Primary error type returned by path-rs APIs.

Errors include enough context to diagnose the failing path or operation. Third-party error types are not exposed as public fields unless necessary.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

EmptyInput

The provided path input was empty after optional trimming.

§

EmbeddedNul

The path contains an embedded NUL byte, which is invalid on all supported platforms.

§

UndefinedEnvironmentVariable

An environment variable referenced during expansion is not defined.

Fields

§name: String

Name of the missing variable.

§

MalformedEnvironmentVariable

Environment variable syntax was malformed (e.g. unclosed %VAR or ${VAR).

Fields

§input: String

The malformed input fragment.

§

HomeDirectoryUnavailable

Home directory could not be determined.

§

CurrentDirectoryUnavailable

Current working directory could not be determined.

Fields

§source: Error

Underlying I/O error.

§

DriveRelativePath

A Windows drive-relative path such as C:foo or C: was encountered.

Fields

§path: String

Display form of the path.

§

AbsoluteChildPath

An absolute child path was supplied where a relative path is required.

Fields

§path: String

Display form of the path.

§

RootEscape

A path escapes the permitted root after normalization.

Fields

§path: String

Display form of the path.

§

NotUtf8

A path is not valid UTF-8 and a UTF-8 conversion was requested.

§

InvalidPath

Generic invalid path condition with a human-readable message.

Fields

§message: String

Description of the problem.

§

Filesystem

A filesystem operation failed.

Fields

§path: String

Display form of the path involved.

§source: Error

Underlying I/O error.

§

Traversal

Directory traversal failed (permission, depth limit, etc.).

Fields

§message: String

Description of the failure.

§

InvalidGlob

A glob pattern is invalid.

Fields

§message: String

Description of the pattern error.

§

Cache

A cache operation failed.

Fields

§message: String

Description of the failure.

§

InvalidAppName

Application name validation failed.

Fields

§message: String

Description of the problem.

§

ExpansionDepthExceeded

Expansion exceeded the maximum allowed depth.

Fields

§max_depth: u32

Configured maximum depth.

Implementations§

Source§

impl PathError

Source

pub fn filesystem(path: impl AsRef<Path>, source: Error) -> Self

Create a filesystem error for path wrapping source.

Source

pub fn invalid(message: impl Into<String>) -> Self

Create an invalid-path error with a message.

Source

pub fn traversal(message: impl Into<String>) -> Self

Create a traversal error with a message.

Source

pub fn cache(message: impl Into<String>) -> Self

Create a cache error with a message.

Source

pub fn root_escape(path: impl AsRef<Path>) -> Self

Create a root-escape error for path.

Source

pub fn absolute_child(path: impl AsRef<Path>) -> Self

Create an absolute-child error for path.

Source

pub fn drive_relative(path: impl AsRef<Path>) -> Self

Create a drive-relative error for path.

Trait Implementations§

Source§

impl Debug for PathError

Source§

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

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

impl Display for PathError

Source§

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

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

impl Error for PathError

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.