arch_pkg_text/value/hex128.rs
1use super::{Hex128, SkipOrHex128, parse_hex::ParseHex};
2
3impl Hex128<'_> {
4 /// Convert the hex string into a 128-bit unsigned integer.
5 pub fn u128(self) -> Option<u128> {
6 let (invalid, value) = ParseHex::parse_hex(self.0);
7 invalid.is_empty().then_some(value)
8 }
9}
10
11impl SkipOrHex128<'_> {
12 /// Convert the hex string into a 128-bit unsigned integer.
13 pub fn u128(self) -> Option<Option<u128>> {
14 if self.as_str() == "SKIP" {
15 return Some(None);
16 }
17 let (invalid, value) = ParseHex::parse_hex(self.0);
18 invalid.is_empty().then_some(Some(value))
19 }
20}