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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#[derive(Debug, Copy, Clone)]
pub enum FrequencyLimit {
All,
Min(f32),
Max(f32),
Range(f32, f32),
}
impl FrequencyLimit {
#[inline(always)]
pub fn maybe_min(&self) -> Option<f32> {
match self {
FrequencyLimit::Min(min) => Some(*min),
FrequencyLimit::Range(min, _) => Some(*min),
_ => None,
}
}
#[inline(always)]
pub fn maybe_max(&self) -> Option<f32> {
match self {
FrequencyLimit::Max(max) => Some(*max),
FrequencyLimit::Range(_, max) => Some(*max),
_ => None,
}
}
#[inline(always)]
pub fn min(&self) -> f32 {
self.maybe_min().expect("Must contain a value!")
}
#[inline(always)]
pub fn max(&self) -> f32 {
self.maybe_max().expect("Must contain a value!")
}
}