Skip to main content

apis_saltans_aps/frame/extended/
control.rs

1use bitflags::bitflags;
2use le_stream::{FromLeStream, ToLeStream};
3
4/// Control field of the extended header.
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash, FromLeStream, ToLeStream)]
6#[repr(transparent)]
7pub struct Control(u8);
8
9bitflags! {
10    impl Control: u8 {
11        /// Indicates whether the extended header is present.
12        const FRAGMENTATION = 0b1100_0000;
13
14        /// Reserved.
15        const RESERVED = 0b0011_1111;
16
17        /// Frame is the first frame of a fragmented transmission.
18        const FIRST_FRAGMENT = 0b0100_0000;
19
20        /// Frame is a follow-up frame of a fragmented transmission.
21        const FOLLOWUP_FRAGMENT = 0b1000_0000;
22    }
23}
24
25impl core::fmt::Display for Control {
26    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
27        bitflags::parser::to_writer(self, formatter)
28    }
29}
30
31impl core::str::FromStr for Control {
32    type Err = bitflags::parser::ParseError;
33
34    fn from_str(flags: &str) -> Result<Self, Self::Err> {
35        bitflags::parser::from_str(flags)
36    }
37}