use std::io;
use thiserror::Error;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Error)]
pub enum Error {
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[error("Serial port error: {0}")]
Serial(#[from] serialport::Error),
#[error("Invalid FWPKG: {0}")]
InvalidFwpkg(String),
#[error("CRC mismatch: expected {expected:#06x}, got {actual:#06x}")]
CrcMismatch {
expected: u16,
actual: u16,
},
#[error("Timeout: {0}")]
Timeout(String),
#[error("Device not found or not in boot mode")]
DeviceNotFound,
#[error("Handshake failed: {0}")]
HandshakeFailed(String),
#[error("Protocol error: {0}")]
Protocol(String),
#[error("YMODEM error: {0}")]
Ymodem(String),
#[error("Unsupported: {0}")]
Unsupported(String),
#[error("Configuration error: {0}")]
Config(String),
}