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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use bitflags::bitflags;
#[derive(Debug, Clone)]
pub struct Descriptor {
pub id: u32,
pub name: String,
pub typ: Type,
pub flags: Flags,
}
impl Descriptor {
pub fn readable(&self) -> bool {
self.flags & Flags::READ == Flags::READ
}
pub fn writable(&self) -> bool {
self.flags & Flags::WRITE == Flags::WRITE
}
}
#[derive(Debug, Clone)]
pub enum Type {
Stateless,
Boolean,
Number {
range: (f64, f64),
step: f32,
},
String,
Bitmask,
Menu(Vec<MenuItem>),
}
#[derive(Debug, Clone)]
pub enum MenuItem {
String(String),
Number(f64),
}
bitflags! {
pub struct Flags: u32 {
const NONE = 0x000;
const READ = 0x001;
const WRITE = 0x002;
}
}
#[derive(Debug, Clone)]
pub enum State {
None,
String(String),
Boolean(bool),
Number(f64),
}