use thiserror::Error;
#[cfg(not(target_os = "linux"))]
mod nix {
#[derive(thiserror::Error, Debug, Copy, Clone)]
pub enum Error {
#[error("")]
Unimplemented,
}
}
#[derive(Error, Debug)]
pub enum NativeTransportError {
#[error("Ledger device not found")]
DeviceNotFound,
#[error("Error opening device. {0}. Hint: This usually means that the device is already in use by another transport instance.")]
CantOpen(hidapi_rusb::HidError),
#[error("Sequence mismatch. Got {got} from device. Expected {expected}")]
SequenceMismatch {
got: u16,
expected: u16,
},
#[error("Ledger device: communication error `{0}`")]
Comm(&'static str),
#[error(transparent)]
Ioctl(#[from] nix::Error),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error(transparent)]
Hid(#[from] hidapi_rusb::HidError),
#[error(transparent)]
UTF8(#[from] std::str::Utf8Error),
#[error("Invalid TERMUX_USB_FD variable. Are you using termux-usb?")]
InvalidTermuxUsbFd,
}