arch_pkg_text/value/
hex128.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use super::{parse_hex::ParseHex, Hex128, SkipOrHex128};

impl Hex128<'_> {
    /// Convert the hex string into a 128-bit unsigned integer.
    pub fn u128(self) -> Option<u128> {
        let (invalid, value) = ParseHex::parse_hex(self.0);
        invalid.is_empty().then_some(value)
    }
}

impl SkipOrHex128<'_> {
    /// Convert the hex string into a 128-bit unsigned integer.
    pub fn u128(self) -> Option<Option<u128>> {
        if self.as_str() == "SKIP" {
            return Some(None);
        }
        let (invalid, value) = ParseHex::parse_hex(self.0);
        invalid.is_empty().then_some(Some(value))
    }
}