simple_someip/protocol/sd/
flags.rs1const REBOOT_FLAG: u8 = 0b1000_0000;
2const UNICAST_FLAG: u8 = 0b0100_0000;
3
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
6pub struct Flags {
7 reboot: bool,
8 unicast: bool,
9}
10
11impl From<u8> for Flags {
12 fn from(value: u8) -> Self {
14 Self {
15 reboot: value & REBOOT_FLAG != 0,
16 unicast: value & UNICAST_FLAG != 0,
17 }
18 }
19}
20
21impl From<Flags> for u8 {
22 fn from(flags: Flags) -> u8 {
23 let mut value = 0;
24 if flags.reboot {
25 value |= REBOOT_FLAG;
26 }
27 if flags.unicast {
28 value |= UNICAST_FLAG;
29 }
30 value
31 }
32}
33
34impl Flags {
35 #[must_use]
37 pub const fn new(reboot: bool, unicast: bool) -> Self {
38 Self { reboot, unicast }
39 }
40 #[must_use]
42 pub const fn new_sd(reboot: bool) -> Self {
43 Self {
44 reboot,
45 unicast: true,
46 }
47 }
48 #[must_use]
50 pub const fn reboot(self) -> bool {
51 self.reboot
52 }
53 #[must_use]
55 pub const fn unicast(self) -> bool {
56 self.unicast
57 }
58}