Skip to main content

ewf_image/
error.rs

1use std::io;
2
3use thiserror::Error;
4
5/// Result type returned by fallible `ewf_image` APIs.
6pub type Result<T> = std::result::Result<T, EwfError>;
7
8/// Error type used by EWF readers, writers, and probe helpers.
9#[derive(Debug, Error)]
10pub enum EwfError {
11    /// An underlying operating-system or stream I/O operation failed.
12    #[error("I/O error: {0}")]
13    Io(#[from] io::Error),
14
15    /// The input does not start with a recognized EWF file signature.
16    #[error("invalid EWF signature")]
17    InvalidSignature,
18
19    /// A caller-provided buffer was too short for the requested operation.
20    #[error("buffer too short: needed {needed} bytes, found {actual}")]
21    BufferTooShort {
22        /// Minimum number of bytes required.
23        needed: usize,
24        /// Number of bytes that were actually available.
25        actual: usize,
26    },
27
28    /// No segment files were found or supplied.
29    #[error("no EWF segments found for {0}")]
30    NoSegments(String),
31
32    /// The image uses a valid EWF feature that this crate does not support.
33    #[error("unsupported EWF feature: {0}")]
34    Unsupported(String),
35
36    /// The operation was cancelled after an abort signal.
37    #[error("operation aborted")]
38    Aborted,
39
40    /// The image or supplied chunk data is structurally invalid.
41    #[error("malformed EWF image: {0}")]
42    Malformed(String),
43}