use thiserror::Error;
#[derive(Debug, Error)]
pub enum OpenBciError {
#[error("Serial port error: {0}")]
SerialPort(#[from] serialport::Error),
#[error("IO error: {0}")]
Io(#[from] std::io::Error),
#[error("Board not ready: {0}")]
BoardNotReady(String),
#[error("Board not yet prepared — call prepare() first")]
BoardNotPrepared,
#[error("Already streaming")]
AlreadyStreaming,
#[error("Not currently streaming")]
NotStreaming,
#[error("WiFi / HTTP error: {0}")]
Wifi(String),
#[cfg(feature = "ble")]
#[error("BLE error: {0}")]
Ble(#[from] btleplug::Error),
#[error("Invalid configuration: {0}")]
InvalidConfig(String),
#[error("Operation timed out")]
Timeout,
#[error("Channel index {0} out of range (board has {1} channels)")]
ChannelOutOfRange(usize, usize),
#[error("Stream channel disconnected")]
StreamDisconnected,
#[error("Packet parse error: {0}")]
PacketParse(String),
}
pub type Result<T> = std::result::Result<T, OpenBciError>;