Skip to main content

qubit_fs/error/
fs_error_kind.rs

1// =============================================================================
2//    Copyright (c) 2026 Haixing Hu.
3//
4//    SPDX-License-Identifier: Apache-2.0
5//
6//    Licensed under the Apache License, Version 2.0.
7// =============================================================================
8//! Filesystem error categories.
9
10/// Provider-neutral filesystem error category.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_fs::error::FsError;
16/// use qubit_fs::error::FsErrorKind;
17/// use qubit_fs::error::FsOperation;
18///
19/// let error = FsError::new(FsErrorKind::NotFound, FsOperation::Stat, "missing object");
20/// assert_eq!(FsErrorKind::NotFound, error.kind());
21/// ```
22#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23#[non_exhaustive]
24pub enum FsErrorKind {
25    /// The requested resource does not exist.
26    NotFound,
27    /// The target resource already exists.
28    AlreadyExists,
29    /// A path component expected to be a directory is not a directory.
30    NotDirectory,
31    /// The requested operation expected a file but found a directory.
32    IsDirectory,
33    /// A provider-local path is invalid for the selected filesystem.
34    InvalidPath,
35    /// A filesystem URI is malformed or violates the credential boundary.
36    InvalidUri,
37    /// Operation options or provider construction input are inconsistent.
38    InvalidOptions,
39    /// A provider returned a value that violates the SPI contract.
40    ProviderContractViolation,
41    /// The current credentials do not grant the requested operation.
42    PermissionDenied,
43    /// Authentication failed before authorization could be evaluated.
44    AuthenticationFailed,
45    /// The selected provider is unavailable in the current environment.
46    ProviderUnavailable,
47    /// The filesystem model does not support the requested operation.
48    UnsupportedOperation,
49    /// A specific stable filesystem capability is not supported.
50    UnsupportedCapability,
51    /// The operation exists but cannot satisfy a required semantic guarantee.
52    RequirementNotMet,
53    /// The handle or resource is not in a state that permits the operation.
54    InvalidState,
55    /// Side effects may have occurred, but their final state is unknown.
56    Indeterminate,
57    /// The operation was cancelled before a definitive result was produced.
58    Cancelled,
59    /// The operation conflicts with current filesystem state.
60    Conflict,
61    /// A conditional operation failed its precondition.
62    PreconditionFailed,
63    /// The operation timed out.
64    Timeout,
65    /// The operation was interrupted.
66    Interrupted,
67    /// A quota, capacity, or storage limit was exceeded.
68    QuotaExceeded,
69    /// A deterministic caller or provider resource bound was exceeded.
70    ResourceLimitExceeded,
71    /// Stored or transferred data failed integrity validation.
72    DataCorruption,
73    /// A lower-level local or remote I/O error occurred.
74    Io,
75    /// An error occurred that does not fit a more specific category.
76    Other,
77}