FsError

Enum FsError 

Source
#[non_exhaustive]
pub enum FsError {
Show 26 variants NotFound { path: PathBuf, }, ThreatDetected { path: PathBuf, reason: String, }, AlreadyExists { path: PathBuf, operation: &'static str, }, NotAFile { path: PathBuf, }, NotADirectory { path: PathBuf, }, DirectoryNotEmpty { path: PathBuf, }, InodeNotFound { inode: u64, }, InvalidHandle { handle: Handle, }, XattrNotFound { path: PathBuf, name: String, }, PermissionDenied { path: PathBuf, operation: &'static str, }, AccessDenied { path: PathBuf, reason: String, }, ReadOnly { operation: &'static str, }, FeatureNotEnabled { feature: &'static str, operation: &'static str, }, QuotaExceeded { limit: u64, requested: u64, usage: u64, }, FileSizeExceeded { path: PathBuf, size: u64, limit: u64, }, RateLimitExceeded { limit: u32, window_secs: u64, }, InvalidData { path: PathBuf, details: String, }, CorruptedData { path: PathBuf, details: String, }, IntegrityError { path: PathBuf, }, Serialization(String), Deserialization(String), NotSupported { operation: &'static str, }, InvalidPassword, Conflict { path: PathBuf, }, Backend(String), Io { operation: &'static str, path: PathBuf, source: Error, },
}
Expand description

Comprehensive filesystem error type.

All AnyFS operations return Result<T, FsError>. Each variant includes relevant context (paths, operations, limits) to make debugging easier.

§Non-Exhaustive

This enum is marked #[non_exhaustive], meaning new variants may be added in future versions without breaking changes. Always include a wildcard arm when pattern matching:

use anyfs_backend::FsError;
use std::path::PathBuf;

fn handle_error(err: FsError) {
    match err {
        FsError::NotFound { path } => println!("Not found: {}", path.display()),
        FsError::PermissionDenied { path, operation } => {
            println!("Permission denied for {} on {}", operation, path.display())
        }
        other => println!("Other error: {}", other),
    }
}

§Display Format

All variants implement Display with human-readable messages:

use anyfs_backend::FsError;
use std::path::PathBuf;

let err = FsError::QuotaExceeded { limit: 100, requested: 50, usage: 80 };
let msg = err.to_string();
assert!(msg.contains("100") && msg.contains("50") && msg.contains("80"));

§Error Source Chain

The Io variant wraps std::io::Error with the #[source] attribute, enabling error chain traversal via std::error::Error::source().

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

NotFound

Path does not exist.

Fields

§path: PathBuf

The path that was not found.

§

ThreatDetected

A threat was detected (e.g., path traversal, malicious content).

Fields

§path: PathBuf

The path where the threat was detected.

§reason: String

Description of the threat.

§

AlreadyExists

Path already exists when it shouldn’t.

Fields

§path: PathBuf

The path that already exists.

§operation: &'static str

The operation that failed.

§

NotAFile

Expected a file but found something else.

Fields

§path: PathBuf

The path that is not a file.

§

NotADirectory

Expected a directory but found something else.

Fields

§path: PathBuf

The path that is not a directory.

§

DirectoryNotEmpty

Directory is not empty when it should be.

Fields

§path: PathBuf

The path to the non-empty directory.

§

InodeNotFound

Inode does not exist.

Fields

§inode: u64

The inode number that was not found.

§

InvalidHandle

File handle is invalid or closed.

Fields

§handle: Handle

The invalid handle.

§

XattrNotFound

Extended attribute not found.

Fields

§path: PathBuf

The path where the xattr was not found.

§name: String

The attribute name that was not found.

§

PermissionDenied

Permission denied for operation.

Fields

§path: PathBuf

The path where permission was denied.

§operation: &'static str

The operation that was denied.

§

AccessDenied

Access denied with reason.

Fields

§path: PathBuf

The path where access was denied.

§reason: String

The reason for denial.

§

ReadOnly

Filesystem is read-only.

Fields

§operation: &'static str

The operation that was attempted.

§

FeatureNotEnabled

Feature is not enabled.

Fields

§feature: &'static str

The feature that is not enabled.

§operation: &'static str

The operation that requires the feature.

§

QuotaExceeded

Quota exceeded.

Fields

§limit: u64

The quota limit.

§requested: u64

The amount requested.

§usage: u64

The current usage.

§

FileSizeExceeded

File size limit exceeded.

Fields

§path: PathBuf

The path to the file.

§size: u64

The actual size.

§limit: u64

The size limit.

§

RateLimitExceeded

Rate limit exceeded.

Fields

§limit: u32

The rate limit.

§window_secs: u64

The time window in seconds.

§

InvalidData

Invalid data encountered.

Fields

§path: PathBuf

The path with invalid data.

§details: String

Details about the invalid data.

§

CorruptedData

Corrupted data detected.

Fields

§path: PathBuf

The path with corrupted data.

§details: String

Details about the corruption.

§

IntegrityError

Data integrity check failed.

Fields

§path: PathBuf

The path that failed integrity check.

§

Serialization(String)

Serialization error.

§

Deserialization(String)

Deserialization error.

§

NotSupported

Operation is not supported.

Fields

§operation: &'static str

The unsupported operation.

§

InvalidPassword

Invalid password provided.

§

Conflict

Conflict detected (e.g., concurrent modification).

Fields

§path: PathBuf

The path with a conflict.

§

Backend(String)

Generic backend error.

§

Io

I/O error with context.

Fields

§operation: &'static str

The operation that failed.

§path: PathBuf

The path involved in the operation.

§source: Error

The underlying I/O error.

Trait Implementations§

Source§

impl Debug for FsError

Source§

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

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

impl Display for FsError

Source§

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

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

impl Error for FsError

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
Source§

impl From<Error> for FsError

Source§

fn from(error: Error) -> Self

Converts to this type from the input type.

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.