#[derive(Debug, thiserror::Error)]
pub enum BrainVisionError {
#[error("Not supported: {0}")]
NotSupported(String),
#[error("Connection error: {0}")]
Connection(String),
#[error("I/O error: {0}")]
Io(String),
#[error("Protocol error: {0}")]
Protocol(String),
#[error("Invalid message: {0}")]
InvalidMessage(String),
#[error("Timeout")]
Timeout,
#[error("Not connected")]
NotConnected,
}
impl From<std::io::Error> for BrainVisionError {
fn from(e: std::io::Error) -> Self {
if e.kind() == std::io::ErrorKind::TimedOut {
BrainVisionError::Timeout
} else {
BrainVisionError::Io(e.to_string())
}
}
}