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 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
use crate::macros::exports::*;
impl_hex! {
/// Pointer-sized unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::HexUsize;
///
/// // from random value
/// let rand = HexUsize::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = HexUsize::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<HexUsize>();
/// assert_eq!(from_str.unwrap(), HexUsize::new(0xa3));
/// ```
pub struct HexUsize(usize);
}
impl_hex! {
/// 128-bit unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::Hex128;
///
/// // from random value
/// let rand = Hex128::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = Hex128::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<Hex128>();
/// assert_eq!(from_str.unwrap(), Hex128::new(0xa3));
/// ```
pub struct Hex128(u128);
}
impl_hex! {
/// 64-bit unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::Hex64;
///
/// // from random value
/// let rand = Hex64::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = Hex64::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<Hex64>();
/// assert_eq!(from_str.unwrap(), Hex64::new(0xa3));
/// ```
pub struct Hex64(u64);
}
impl_hex! {
/// 32-bit unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::Hex32;
///
/// // from random value
/// let rand = Hex32::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = Hex32::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<Hex32>();
/// assert_eq!(from_str.unwrap(), Hex32::new(0xa3));
/// ```
pub struct Hex32(u32);
}
impl_hex! {
/// 16-bit unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::Hex16;
///
/// // from random value
/// let rand = Hex16::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = Hex16::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<Hex16>();
/// assert_eq!(from_str.unwrap(), Hex16::new(0xa3));
/// ```
pub struct Hex16(u16);
}
impl_hex! {
/// 8-bit unsigned hexadecimal numbers.
///
/// ```rust
/// use hex_wrapper::Hex8;
///
/// // from random value
/// let rand = Hex8::rand();
/// let inner = rand.get();
/// assert_eq!(rand.to_string(), format!("{:x}", inner));
///
/// // from given value
/// let given = Hex8::new(0xa3);
/// assert_eq!(given.to_string(), String::from("a3"));
///
/// // from string
/// let from_str = "a3".parse::<Hex8>();
/// assert_eq!(from_str.unwrap(), Hex8::new(0xa3));
/// ```
pub struct Hex8(u8);
}
