use thiserror::Error;
pub type Result<T> = std::result::Result<T, BoardError>;
#[derive(Debug, Error)]
pub enum BoardError {
#[error("{0}")]
Msg(String),
#[error(transparent)]
Other(#[from] anyhow::Error),
#[error("HID 错误: {0}")]
Hid(String),
#[error("BLE 错误: {0}")]
Ble(String),
#[error(transparent)]
Io(#[from] std::io::Error),
#[error("命令超时: {0}")]
Timeout(String),
#[error("协议错误: {0}")]
Protocol(String),
#[error("设备未连接")]
NotConnected,
#[error("SDK 未启动")]
NotStarted,
}
impl BoardError {
pub fn msg<S: Into<String>>(s: S) -> Self {
Self::Msg(s.into())
}
}