style/values/specified/
frequency.rs1use crate::derives::*;
8use cssparser::match_ignore_ascii_case;
9
10#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd, ToShmem)]
12#[repr(u8)]
13pub enum FrequencyUnit {
14 Hz,
16 Khz,
18}
19
20impl FrequencyUnit {
21 #[inline]
23 pub fn from_str(unit: &str) -> Result<Self, ()> {
24 Ok(match_ignore_ascii_case! { unit,
25 "hz" => Self::Hz,
26 "khz" => Self::Khz,
27 _ => return Err(())
28 })
29 }
30
31 #[inline]
33 pub fn as_str(self) -> &'static str {
34 match self {
35 Self::Hz => "hz",
36 Self::Khz => "khz",
37 }
38 }
39}