hex_wrapper/zeroable.rs
1impl_hex! {
2 /// Pointer-sized unsigned hexadecimal numbers.
3 ///
4 /// ```rust
5 /// use hex_wrapper::HexUsize;
6 ///
7 /// // from random value
8 /// let rand = HexUsize::rand();
9 /// let inner = rand.get();
10 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
11 ///
12 /// // from given value
13 /// let given = HexUsize::new(0xa3);
14 /// assert_eq!(given.to_string(), String::from("a3"));
15 ///
16 /// // from string
17 /// let from_str = "a3".parse::<HexUsize>();
18 /// assert_eq!(from_str.unwrap(), HexUsize::new(0xa3));
19 /// ```
20 pub struct HexUsize(usize);
21}
22
23impl_hex! {
24 /// 128-bit unsigned hexadecimal numbers.
25 ///
26 /// ```rust
27 /// use hex_wrapper::Hex128;
28 ///
29 /// // from random value
30 /// let rand = Hex128::rand();
31 /// let inner = rand.get();
32 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
33 ///
34 /// // from given value
35 /// let given = Hex128::new(0xa3);
36 /// assert_eq!(given.to_string(), String::from("a3"));
37 ///
38 /// // from string
39 /// let from_str = "a3".parse::<Hex128>();
40 /// assert_eq!(from_str.unwrap(), Hex128::new(0xa3));
41 /// ```
42 pub struct Hex128(u128);
43}
44
45impl_hex! {
46 /// 64-bit unsigned hexadecimal numbers.
47 ///
48 /// ```rust
49 /// use hex_wrapper::Hex64;
50 ///
51 /// // from random value
52 /// let rand = Hex64::rand();
53 /// let inner = rand.get();
54 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
55 ///
56 /// // from given value
57 /// let given = Hex64::new(0xa3);
58 /// assert_eq!(given.to_string(), String::from("a3"));
59 ///
60 /// // from string
61 /// let from_str = "a3".parse::<Hex64>();
62 /// assert_eq!(from_str.unwrap(), Hex64::new(0xa3));
63 /// ```
64 pub struct Hex64(u64);
65}
66
67impl_hex! {
68 /// 32-bit unsigned hexadecimal numbers.
69 ///
70 /// ```rust
71 /// use hex_wrapper::Hex32;
72 ///
73 /// // from random value
74 /// let rand = Hex32::rand();
75 /// let inner = rand.get();
76 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
77 ///
78 /// // from given value
79 /// let given = Hex32::new(0xa3);
80 /// assert_eq!(given.to_string(), String::from("a3"));
81 ///
82 /// // from string
83 /// let from_str = "a3".parse::<Hex32>();
84 /// assert_eq!(from_str.unwrap(), Hex32::new(0xa3));
85 /// ```
86 pub struct Hex32(u32);
87}
88
89impl_hex! {
90 /// 16-bit unsigned hexadecimal numbers.
91 ///
92 /// ```rust
93 /// use hex_wrapper::Hex16;
94 ///
95 /// // from random value
96 /// let rand = Hex16::rand();
97 /// let inner = rand.get();
98 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
99 ///
100 /// // from given value
101 /// let given = Hex16::new(0xa3);
102 /// assert_eq!(given.to_string(), String::from("a3"));
103 ///
104 /// // from string
105 /// let from_str = "a3".parse::<Hex16>();
106 /// assert_eq!(from_str.unwrap(), Hex16::new(0xa3));
107 /// ```
108 pub struct Hex16(u16);
109}
110
111impl_hex! {
112 /// 8-bit unsigned hexadecimal numbers.
113 ///
114 /// ```rust
115 /// use hex_wrapper::Hex8;
116 ///
117 /// // from random value
118 /// let rand = Hex8::rand();
119 /// let inner = rand.get();
120 /// assert_eq!(rand.to_string(), format!("{:x}", inner));
121 ///
122 /// // from given value
123 /// let given = Hex8::new(0xa3);
124 /// assert_eq!(given.to_string(), String::from("a3"));
125 ///
126 /// // from string
127 /// let from_str = "a3".parse::<Hex8>();
128 /// assert_eq!(from_str.unwrap(), Hex8::new(0xa3));
129 /// ```
130 pub struct Hex8(u8);
131}