1#[derive(Clone, Copy)]
5pub struct Bps(pub u32);
6
7#[derive(Clone, Copy)]
9pub struct Hertz(pub u32);
10
11#[derive(Clone, Copy)]
13pub struct KiloHertz(pub u32);
14
15#[derive(Clone, Copy)]
17pub struct MegaHertz(pub u32);
18
19pub trait U32Ext {
21 fn bps(self) -> Bps;
23
24 fn hz(self) -> Hertz;
26
27 fn khz(self) -> KiloHertz;
29
30 fn mhz(self) -> MegaHertz;
32}
33
34impl U32Ext for u32 {
35 fn bps(self) -> Bps {
36 Bps(self)
37 }
38
39 fn hz(self) -> Hertz {
40 Hertz(self)
41 }
42
43 fn khz(self) -> KiloHertz {
44 KiloHertz(self)
45 }
46
47 fn mhz(self) -> MegaHertz {
48 MegaHertz(self)
49 }
50}
51
52impl Into<Hertz> for KiloHertz {
53 fn into(self) -> Hertz {
54 Hertz(self.0 * 1_000)
55 }
56}
57
58impl Into<Hertz> for MegaHertz {
59 fn into(self) -> Hertz {
60 Hertz(self.0 * 1_000_000)
61 }
62}
63
64impl Into<KiloHertz> for MegaHertz {
65 fn into(self) -> KiloHertz {
66 KiloHertz(self.0 * 1_000)
67 }
68}