1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use ffi::*;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use sys::SwrEngine::*;

#[derive(Eq, PartialEq, Copy, Clone, Debug)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub enum Engine {
    Software,
    SoundExchange,
}

impl From<SwrEngine> for Engine {
    fn from(value: SwrEngine) -> Engine {
        match value {
            SWR_ENGINE_SWR => Engine::Software,
            SWR_ENGINE_SOXR => Engine::SoundExchange,
            SWR_ENGINE_NB => Engine::Software,

            #[cfg(feature = "non-exhaustive-enums")]
            _ => unimplemented!(),
        }
    }
}

impl From<Engine> for SwrEngine {
    fn from(value: Engine) -> SwrEngine {
        match value {
            Engine::Software => SWR_ENGINE_SWR,
            Engine::SoundExchange => SWR_ENGINE_SOXR,
        }
    }
}