1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum VhdError {
5 #[error("I/O error: {0}")]
6 Io(#[from] std::io::Error),
7 #[error("not a VHD file (bad cookie)")]
8 BadCookie,
9 #[error("unsupported VHD version: {0:#010x}")]
10 UnsupportedVersion(u32),
11 #[error("differencing disks are not supported")]
12 DifferencingNotSupported,
13 #[error("unknown disk type: {0}")]
14 UnknownDiskType(u32),
15 #[error("file too small to be a valid VHD")]
16 FileTooSmall,
17 #[error("footer checksum mismatch (expected {expected:#010x}, got {actual:#010x})")]
18 ChecksumMismatch { expected: u32, actual: u32 },
19 #[error("BAT offset out of bounds")]
20 BatOutOfBounds,
21 #[error("block data offset out of bounds")]
22 BlockOutOfBounds,
23 #[error("block_size must be > 0")]
24 InvalidBlockSize,
25}
26
27pub type Result<T> = std::result::Result<T, VhdError>;