#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Usb(#[from] rusb::Error),
#[error(transparent)]
IO(#[from] std::io::Error),
#[error("the device to connect to was not found")]
DeviceNotFound,
#[error("the device is no longer available")]
DeviceDisconnected,
#[error("the device produced a data chunk of unexpected size")]
UnexpectedChunkSizeFromDevice(usize),
#[error("timeout expired while reading from device")]
DeviceReadTimeout,
#[error("the device sent a chunk with a wrong magic value")]
DeviceBadMagic,
#[error("the device sent a message with a wrong session id")]
DeviceBadSessionId,
#[error("the device sent an unexpected sequence number")]
DeviceUnexpectedSequenceNumber,
#[error("received a non-existing message type from the device")]
InvalidMessageType(u32),
#[error("unable to determine device serial number")]
NoDeviceSerial,
}