pulith_verify/error.rs
1use std::io;
2use thiserror::Error;
3
4/// Error types for verification operations.
5///
6/// Follows the error handling patterns specified in [AGENT.md](../../docs/AGENT.md).
7#[derive(Error, Debug)]
8pub enum VerifyError {
9 /// Hash mismatch between expected and actual digest
10 #[error("hash mismatch: expected {expected:?}, got {actual:?}")]
11 HashMismatch {
12 /// The expected hash digest
13 expected: Vec<u8>,
14 /// The actual computed hash digest
15 actual: Vec<u8>,
16 },
17
18 /// Processed stream length did not match expectation
19 #[error("stream length mismatch: expected {expected} bytes, got {actual}")]
20 SizeMismatch {
21 /// Expected number of bytes to be processed
22 expected: u64,
23 /// Actual number of bytes processed
24 actual: u64,
25 },
26
27 /// I/O error during verification process
28 #[error("I/O error during verification: {0}")]
29 Io(#[from] io::Error),
30
31 /// Hexadecimal decoding error when parsing expected hash
32 #[error("hex decoding error: {0}")]
33 HexDecode(#[from] hex::FromHexError),
34}
35
36/// Result type alias for verification operations.
37pub type Result<T> = std::result::Result<T, VerifyError>;