#[non_exhaustive]pub enum SegmentError {
Io {
site: IoSite,
source: Error,
},
Cbor {
phase: &'static str,
path: PathBuf,
message: String,
},
Cipher {
path: PathBuf,
message: String,
},
Integrity {
path: PathBuf,
reason: &'static str,
},
Locked {
path: PathBuf,
},
}Expand description
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Io
Filesystem I/O failure (directory creation, segment read/write, rename, etc.).
Carries the IoSite the failure happened on plus the underlying
std::io::Error as source. When ? propagates an io::Error
without context, the site is IoSite::Unknown; use
with_path (or
with_dir) to attach the site at high-value call
sites.
Fields
source: ErrorThe underlying io::Error, reachable via std::error::Error::source.
Cbor
CBOR serialization or deserialization of a segment file failed.
Fields
Cipher
Cipher encrypt or decrypt of a segment file failed (key mismatch, AEAD tag invalid, cipher misconfiguration).
Fields
Integrity
Segment file failed an integrity check: truncated, too small for the AEAD nonce, or unrecognized envelope.
Fields
Locked
Another process holds the exclusive single-process lock on the buffer
directory. Returned by crate::SegmentBuffer::open when the
flock on .segment-buffer.lock cannot be acquired. See
AGENTS.md § “Single-process invariant”.
Implementations§
Source§impl SegmentError
impl SegmentError
Sourcepub fn with_path(self, path: impl Into<PathBuf>) -> Self
pub fn with_path(self, path: impl Into<PathBuf>) -> Self
Attach a segment-file path to an existing SegmentError::Io variant
whose site is IoSite::Unknown. Returns the error unchanged for
other variants or for Io errors already tagged (Dir or Segment) —
the first call site to attach context wins.
Use SegmentError::with_dir for operations on the directory itself
(create_dir_all, scan, clean_tmp, dir fsync).
Sourcepub fn with_dir(self) -> Self
pub fn with_dir(self) -> Self
Tag an IoSite::Unknown Io error as a directory operation. Returns
the error unchanged for other variants or for Io errors already
tagged (Dir or Segment). Use this at directory-operation call sites
(create_dir_all, scan, clean_tmp, dir fsync) so operators can
distinguish “the directory itself failed” from “a specific segment
file failed.”
Trait Implementations§
Source§impl Debug for SegmentError
impl Debug for SegmentError
Source§impl Display for SegmentError
impl Display for SegmentError
Source§impl Error for SegmentError
impl Error for SegmentError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()