launchkey_sdk/launchkey/surface/
faders.rs

1use crate::bidirectional_enum_mappings;
2use strum::IntoEnumIterator;
3use strum_macros::EnumIter;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumIter)]
6pub enum Fader {
7    Fader1,
8    Fader2,
9    Fader3,
10    Fader4,
11    Fader5,
12    Fader6,
13    Fader7,
14    Fader8,
15    Fader9,
16}
17
18bidirectional_enum_mappings!(Fader, u8, {
19    Fader1 => 0x05,
20    Fader2 => 0x06,
21    Fader3 => 0x07,
22    Fader4 => 0x08,
23    Fader5 => 0x09,
24    Fader6 => 0x0A,
25    Fader7 => 0x0B,
26    Fader8 => 0x0C,
27    Fader9 => 0x0D,
28});
29
30impl Fader {
31    /// Get all possible variants of `Fader`.
32    pub fn all() -> impl Iterator<Item = Self> {
33        Self::iter()
34    }
35
36    /// Get the count of all variants
37    pub fn count() -> usize {
38        Self::all().count()
39    }
40
41    /// Safely get a variant by its index
42    pub fn from_index(index: usize) -> Option<Self> {
43        Self::all().nth(index)
44    }
45}