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
use anyhow::Result;

#[async_trait::async_trait]
pub trait SyncAndChannelCoding {
    async fn transmit(
        &mut self,
        scid: u16,
        vcid: u8,
        frame_type: FrameType,
        sequence_number: u8,
        data_field: &[u8],
    ) -> Result<()>;
}

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FrameType {
    TypeAD,
    TypeBD,
    TypeBC,
}

impl FrameType {
    pub fn bypass_flag(&self) -> bool {
        match self {
            FrameType::TypeAD => false,
            FrameType::TypeBD => true,
            FrameType::TypeBC => true,
        }
    }

    pub fn control_command_flag(&self) -> bool {
        match self {
            FrameType::TypeAD => false,
            FrameType::TypeBD => false,
            FrameType::TypeBC => true,
        }
    }
}