Skip to main content

nominal_api/conjure/objects/scout/compute/api/
magnitude_scaling.rs

1#![allow(deprecated)]
2use std::fmt;
3use std::str;
4#[derive(
5    Debug,
6    Clone,
7    PartialEq,
8    Eq,
9    PartialOrd,
10    Ord,
11    Hash,
12    conjure_object::serde::Deserialize,
13    conjure_object::serde::Serialize,
14)]
15#[serde(crate = "conjure_object::serde")]
16pub enum MagnitudeScaling {
17    /// Linear scaling of the magnitude.
18    #[serde(rename = "LINEAR")]
19    Linear,
20    /// Scales the magnitude via 10 * log10(magnitude).
21    #[serde(rename = "MAGNITUDE_DB_10")]
22    MagnitudeDb10,
23    /// Scales the magnitude via 20 * log10(magnitude).
24    #[serde(rename = "MAGNITUDE_DB_20")]
25    MagnitudeDb20,
26    /// An unknown variant.
27    #[serde(untagged)]
28    Unknown(Unknown),
29}
30impl MagnitudeScaling {
31    /// Returns the string representation of the enum.
32    #[inline]
33    pub fn as_str(&self) -> &str {
34        match self {
35            MagnitudeScaling::Linear => "LINEAR",
36            MagnitudeScaling::MagnitudeDb10 => "MAGNITUDE_DB_10",
37            MagnitudeScaling::MagnitudeDb20 => "MAGNITUDE_DB_20",
38            MagnitudeScaling::Unknown(v) => &*v,
39        }
40    }
41}
42impl fmt::Display for MagnitudeScaling {
43    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
44        fmt::Display::fmt(self.as_str(), fmt)
45    }
46}
47impl conjure_object::Plain for MagnitudeScaling {
48    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
49        conjure_object::Plain::fmt(self.as_str(), fmt)
50    }
51}
52impl str::FromStr for MagnitudeScaling {
53    type Err = conjure_object::plain::ParseEnumError;
54    #[inline]
55    fn from_str(
56        v: &str,
57    ) -> Result<MagnitudeScaling, conjure_object::plain::ParseEnumError> {
58        match v {
59            "LINEAR" => Ok(MagnitudeScaling::Linear),
60            "MAGNITUDE_DB_10" => Ok(MagnitudeScaling::MagnitudeDb10),
61            "MAGNITUDE_DB_20" => Ok(MagnitudeScaling::MagnitudeDb20),
62            v => v.parse().map(|v| MagnitudeScaling::Unknown(Unknown(v))),
63        }
64    }
65}
66impl conjure_object::FromPlain for MagnitudeScaling {
67    type Err = conjure_object::plain::ParseEnumError;
68    #[inline]
69    fn from_plain(
70        v: &str,
71    ) -> Result<MagnitudeScaling, conjure_object::plain::ParseEnumError> {
72        v.parse()
73    }
74}
75///An unknown variant of the MagnitudeScaling enum.
76#[derive(
77    Debug,
78    Clone,
79    PartialEq,
80    Eq,
81    PartialOrd,
82    Ord,
83    Hash,
84    conjure_object::serde::Deserialize,
85    conjure_object::serde::Serialize,
86)]
87#[serde(crate = "conjure_object::serde", transparent)]
88pub struct Unknown(conjure_object::private::Variant);
89impl std::ops::Deref for Unknown {
90    type Target = str;
91    #[inline]
92    fn deref(&self) -> &str {
93        &self.0
94    }
95}
96impl fmt::Display for Unknown {
97    #[inline]
98    fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
99        fmt::Display::fmt(&self.0, fmt)
100    }
101}