Skip to main content

segment_buffer/
error.rs

1//! Error types for segment-buffer.
2
3use std::io;
4
5/// Errors produced by segment-buffer operations.
6#[derive(Debug, thiserror::Error)]
7#[non_exhaustive]
8pub enum SegmentError {
9    /// Filesystem I/O failure (directory creation, segment read/write, rename, etc.).
10    #[error("I/O error: {0}")]
11    Io(#[from] io::Error),
12    /// CBOR serialization or deserialization failure.
13    #[error("CBOR error: {0}")]
14    Cbor(String),
15    /// Encryption or decryption failure (cipher misconfiguration, key mismatch, etc.).
16    #[error("cipher error: {0}")]
17    Cipher(String),
18    /// Segment file failed an integrity check (truncated, corrupted, nonce missing).
19    #[error("segment integrity failure: {0}")]
20    Integrity(String),
21}
22
23/// Result alias used throughout the crate.
24pub type Result<T> = std::result::Result<T, SegmentError>;