lasprs 0.8.0

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
Documentation
//! Provides stream messages that come from a running stream
use strum_macros::{Display, EnumMessage};

use super::*;

/// Gives the stream status of a (possible) stream, either input / output or duplex.
#[derive(EnumMessage, Debug, Clone, Copy, Display, PartialEq)]
#[cfg_attr(feature = "python-bindings", pyclass)]
pub enum StreamStatus {
    /// Stream is not running
    #[strum(message = "NotRunning", detailed_message = "Stream is not running")]
    NotRunning {},
    /// Stream is running properly
    #[strum(message = "Running", detailed_message = "Stream is running")]
    Running {},

    /// An error occured in the stream.
    #[strum(
        message = "Error",
        detailed_message = "An error occured with the stream"
    )]
    Error {
        /// In case the stream has an error: e is the field name
        e: StreamError,
    },
}

#[cfg(feature = "python-bindings")]
#[cfg_attr(feature = "python-bindings", pymethods)]
impl StreamStatus {
    fn __eq__(&self, other: &Self) -> bool {
        self == other
    }
    fn hasError(&self) -> bool {
        matches!(self, StreamStatus::Error { .. })
    }
    fn getError(&self) -> Option<StreamError> {
        use StreamStatus::*;
        if let Error { e } = self {
            return Some(*e);
        }
        None
    }
}