1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub struct Config {
3 pub free_tone_marking: bool,
4 pub std_tone_style: bool,
5 pub auto_correct: bool,
6}
7
8impl Default for Config {
9 fn default() -> Self {
10 Self {
11 free_tone_marking: true,
12 std_tone_style: true,
13 auto_correct: true,
14 }
15 }
16}
17
18impl Config {
19 pub fn new() -> Self {
20 Self::default()
21 }
22
23 pub(crate) fn to_flags(self) -> u32 {
24 let mut flags = 0;
25 if self.free_tone_marking {
26 flags |= 1 << 0;
27 }
28 if self.std_tone_style {
29 flags |= 1 << 1;
30 }
31 if self.auto_correct {
32 flags |= 1 << 2;
33 }
34 flags
35 }
36
37 pub fn from_flags(flags: u32) -> Self {
38 Self {
39 free_tone_marking: (flags & (1 << 0)) != 0,
40 std_tone_style: (flags & (1 << 1)) != 0,
41 auto_correct: (flags & (1 << 2)) != 0,
42 }
43 }
44}