lasprs 0.14.1

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
use crate::{config::*, siggen::SiggenError};
use snafu::prelude::*;
use std::sync::Arc;
use strum::EnumMessage;
use strum_macros::Display;

/// Errors that happen in a stream
#[allow(missing_docs)]
#[cfg_attr(
    feature = "python-bindings",
    gen_stub_pyclass_complex_enum,
    pyclass(from_py_object)
)]
#[derive(PartialEq, Debug, Snafu, Clone)]
#[snafu(visibility(pub(crate)))]
pub enum StreamError {
    #[snafu(display("Input buffer overrun error"))]
    InputOverrun {},

    #[snafu(display("Output buffer overrun error"))]
    OutputUnderrun {},

    /// Driver specific error
    #[snafu(display("Driver error: {}", msg))]
    DriverError { msg: String },

    /// Device
    #[snafu(display("device '{device_name}' not available (anymore)"))]
    DeviceNotAvailable { device_name: String },

    /// Logic error (Probably a bug)
    #[snafu(display("number of frames send / receive mismatch with expected"))]
    FramesMismatchError {},

    #[snafu(display("data type mismatch"))]
    DTypeMismatchError {},

    /// System error (something weird happened)
    #[snafu(display("system error: {}", msg))]
    SystemError { msg: String },

    /// Signal generator error
    #[snafu(display("Signal generator error"))]
    SiggenError { source: SiggenError },
}

#[cfg_attr(feature = "python-bindings", gen_stub_pymethods)]
#[cfg_attr(feature = "python-bindings", pymethods)]
impl StreamError {
    fn __str__(&self) -> String {
        format!("{}", self)
    }
}