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 /// A recognized encrypted EWF image was opened without a password.
33 #[error("password required for encrypted EWF image")]
34 PasswordRequired,
35
36 /// An encrypted EWF password verifier rejected the supplied password.
37 #[error("password rejected for encrypted EWF image")]
38 PasswordRejected,
39
40 /// Decrypted EWF data did not pass the format's structural validation.
41 #[error("decrypted EWF data failed validation")]
42 DecryptionValidationFailed,
43
44 /// The image uses a valid EWF feature that this crate does not support.
45 #[error("unsupported EWF feature: {0}")]
46 Unsupported(String),
47
48 /// The operation was cancelled after an abort signal.
49 #[error("operation aborted")]
50 Aborted,
51
52 /// The image or supplied chunk data is structurally invalid.
53 #[error("malformed EWF image: {0}")]
54 Malformed(String),
55}