nvme/ds/
mod.rs

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
use std::time::Duration;

pub mod cmd;
pub mod controller;
pub mod identify;
pub mod namespace;
pub mod queue;
pub mod sgl;
pub mod status;
pub mod uuid;

pub type Address = u64;

pub type InterruptVector = u16;

#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct OneHundredMilliseconds(u16);

impl From<OneHundredMilliseconds> for Duration {
    fn from(o: OneHundredMilliseconds) -> Self {
        Duration::from_millis(o.0 as u64 * 100)
    }
}

#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Microseconds(u32);

impl From<Microseconds> for Duration {
    fn from(m: Microseconds) -> Self {
        Duration::from_micros(m.0 as u64)
    }
}

#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Minutes(u16);

impl From<Minutes> for Duration {
    fn from(m: Minutes) -> Self {
        Duration::from_millis(m.0 as u64 * 1000 * 60)
    }
}

#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct Seconds(u8);

impl From<Seconds> for Duration {
    fn from(m: Seconds) -> Self {
        Duration::from_millis(m.0 as u64 * 1000)
    }
}

use modular_bitfield::prelude::*;

#[bitfield]
#[derive(BitfieldSpecifier, Default, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct HalfSeconds(u8);

impl From<HalfSeconds> for Duration {
    fn from(m: HalfSeconds) -> Self {
        Duration::from_millis(m.get_0() as u64 * 500)
    }
}