use thiserror::Error;
#[derive(Debug, Error)]
pub enum UsbSidError {
#[error("USBSID driver not initialised")]
NotInitialised,
#[error("USBSID port is not open")]
PortNotOpen,
#[error("USBSID-Pico device not found (VID=0x{vid:04X} PID=0x{pid:04X})")]
DeviceNotFound {
vid: u16,
pid: u16,
},
#[cfg(feature = "usb")]
#[error("USB error: {0}")]
Usb(#[from] rusb::Error),
#[error("Thread error: {0}")]
Thread(String),
#[error("Operation not supported while threaded mode is active")]
ThreadedModeActive,
#[error("Ring write requires threaded={expected_threaded}, withcycles={expected_cycled}")]
WrongThreadMode {
expected_threaded: bool,
expected_cycled: bool,
},
}
pub type Result<T> = std::result::Result<T, UsbSidError>;