neurosky 0.0.1

Rust library and TUI for NeuroSky MindWave EEG headsets via the ThinkGear serial protocol
Documentation
//! Error types for the NeuroSky ThinkGear API wrapper.

/// All errors that can occur within the NeuroSky MindWave library.
#[derive(Debug, thiserror::Error)]
pub enum NeuroSkyError {
    /// A feature is not supported on this platform.
    #[error("Not supported: {0}")]
    NotSupported(String),

    /// A serial port I/O error occurred.
    #[error("Serial port error: {0}")]
    SerialPort(String),

    /// No MindWave device or serial port was found.
    #[error("No device found")]
    NoDeviceFound,

    /// The device is not connected.
    #[error("Not connected")]
    NotConnected,

    /// A ThinkGear packet checksum did not match.
    #[error("Checksum mismatch")]
    ChecksumMismatch,

    /// A read operation timed out.
    #[error("Timeout")]
    Timeout,

    /// A received packet was structurally invalid.
    #[error("Invalid packet: {0}")]
    InvalidPacket(String),
}

impl From<serialport::Error> for NeuroSkyError {
    fn from(e: serialport::Error) -> Self {
        NeuroSkyError::SerialPort(e.to_string())
    }
}