reflex/storage/nvme/
error.rs

1use std::path::PathBuf;
2use thiserror::Error;
3
4use crate::storage::mmap::MmapError;
5
6#[derive(Error, Debug)]
7/// Errors returned by the NVMe storage backend.
8pub enum NvmeError {
9    /// IO error.
10    #[error("I/O error: {0}")]
11    Io(#[from] std::io::Error),
12
13    /// Mmap error.
14    #[error("mmap error: {0}")]
15    Mmap(#[from] MmapError),
16
17    /// Serialization/deserialization error.
18    #[error("serialization error: {0}")]
19    Serialization(String),
20
21    /// Entry was not found.
22    #[error("entry not found: tenant={tenant_id}, id={entry_id}")]
23    NotFound {
24        /// Tenant id.
25        tenant_id: u64,
26        /// Entry id.
27        entry_id: u64,
28    },
29
30    /// Storage root path is missing/unavailable.
31    #[error("storage path unavailable: {path}")]
32    StorageUnavailable {
33        /// Path that was unavailable.
34        path: PathBuf,
35    },
36
37    /// Failed to create the tenant directory.
38    #[error("failed to create tenant directory: {path}")]
39    TenantDirCreationFailed {
40        /// Directory path.
41        path: PathBuf,
42    },
43}
44
45/// Convenience result type for NVMe storage operations.
46pub type NvmeResult<T> = Result<T, NvmeError>;