use std::io;
use thiserror::Error;
#[derive(Error, Debug)]
pub enum Error {
#[error("IO error: {0}")]
Io(#[from] io::Error),
#[error("Invalid signature: expected '{expected}', found '{found}'")]
InvalidSignature { expected: String, found: String },
#[error("Checksum mismatch: expected {expected:#010x}, calculated {calculated:#010x}")]
ChecksumMismatch { expected: u32, calculated: u32 },
#[error("Sequence number mismatch: primary={primary}, secondary={secondary}")]
SequenceMismatch { primary: u32, secondary: u32 },
#[error("Invalid cell offset: {0:#010x}")]
InvalidCellOffset(u32),
#[error("Invalid cell size: {0}")]
InvalidCellSize(i32),
#[error("Cell at offset {0:#010x} is unallocated")]
UnallocatedCell(u32),
#[error("Unknown cell type: {0:?}")]
UnknownCellType([u8; 2]),
#[error("Invalid hive bin at offset {offset:#010x}: {message}")]
InvalidHiveBin { offset: u32, message: String },
#[error("Key not found: {0}")]
KeyNotFound(String),
#[error("Value not found: {0}")]
ValueNotFound(String),
#[error("Invalid UTF-16 string")]
InvalidUtf16String,
#[error("Invalid data type: {0}")]
InvalidDataType(u32),
#[error("Data too large: {size} bytes (max: {max})")]
DataTooLarge { size: usize, max: usize },
#[error("Buffer too small: need {needed} bytes, have {available}")]
BufferTooSmall { needed: usize, available: usize },
#[error("Unsupported hive version: {major}.{minor} (supported: 1.3-1.6)")]
UnsupportedVersion { major: u32, minor: u32 },
#[error("Corrupt hive: {0}")]
CorruptHive(String),
#[error("Invalid registry path: {0}")]
InvalidPath(String),
}
pub type Result<T> = std::result::Result<T, Error>;