lasprs 0.14.1

Library for Acoustic Signal Processing (Rust edition, with optional Python bindings via pyo3)
use crate::*;
use snafu::prelude::*;
use std::fmt::{Display, Formatter};
#[allow(missing_docs)]
#[derive(Debug, Snafu, Clone, PartialEq)]
#[snafu(visibility(pub(crate)))]
#[cfg_attr(
    feature = "python-bindings",
    gen_stub_pyclass_complex_enum,
    pyclass(from_py_object)
)]
pub enum FilterError {
    SamplingFrequencyTooLow {},
    ChannelIndexOutOfBounds {},
    InvalidFilterOrder {},
    InvalidBiquadInitialization { msg: String },
}

cfg_select! {
    feature = "python-bindings" => {
        use pyo3::exceptions::PyException;
        #[gen_stub_pyclass]
        #[pyclass(extends = PyException, str, from_py_object)] // or PyBaseException
        /// Wrapper for FilterError, to make it a struct, not enum, as enums cannot
        /// be extended from PyBaseException.
        #[derive(Debug, Clone)]
        pub struct PyFilterError {
            /// The inner error
            #[pyo3(get)]
            pub inner: FilterError,
        }
        impl Display for PyFilterError {
            fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
                write!(f, "{}", self.inner)
            }
        }
        #[gen_stub_pymethods]
        #[pymethods]
        impl PyFilterError {
            /// Create a new PyStreamMgrError from a StreamMgrError
            #[new]
            fn new(inner: FilterError) -> Self {
                PyFilterError { inner }
            }
        }

        impl From<FilterError> for PyErr {
            fn from(value: FilterError) -> Self {
                // let err = PyStreamMgrError {inner: value};
                // PyErr::from_value(err.into())
                PyErr::new::<PyFilterError, _>(value)
            }
        }
    },
    _ => {}
}