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
use modular_bitfield::bitfield;

pub mod comentry;
pub mod subentry;

use modular_bitfield::prelude::*;

#[bitfield]
#[derive(BitfieldSpecifier, Clone, Copy, Debug)]
#[repr(transparent)]
pub struct QueueSize(u16);

#[bitfield]
#[derive(BitfieldSpecifier, Clone, Copy, Debug)]
#[repr(transparent)]
pub struct QueueId(u16);

impl QueueId {
    pub const ADMIN: Self = Self::new();
}

impl From<u16> for QueueId {
    fn from(x: u16) -> Self {
        QueueId::new().with_0(x)
    }
}

impl From<QueueId> for usize {
    fn from(qi: QueueId) -> Self {
        qi.get_0().into()
    }
}

impl From<QueueId> for u16 {
    fn from(qi: QueueId) -> Self {
        qi.get_0()
    }
}

#[bitfield]
#[derive(BitfieldSpecifier, Clone, Copy, Debug)]
#[repr(transparent)]
pub struct CommandId(u16);

impl From<u16> for CommandId {
    fn from(x: u16) -> Self {
        CommandId::new().with_0(x)
    }
}

impl From<CommandId> for u16 {
    fn from(x: CommandId) -> Self {
        x.get_0()
    }
}

impl From<u16> for QueueSize {
    fn from(x: u16) -> Self {
        QueueSize::new().with_0(x)
    }
}

impl From<QueueSize> for u16 {
    fn from(x: QueueSize) -> Self {
        x.get_0()
    }
}

#[derive(BitfieldSpecifier)]
#[bits = 2]
pub enum QueuePriority {
    Urgent,
    High,
    Medium,
    Low,
}