fashex 0.0.4

Conversion from bytes to hexadecimal string.
Documentation
//! Utilities

// TODO: migrate to our owned implementation?
#[cfg(all(
    feature = "runtime-cpu-detection",
    any(
        target_arch = "x86",
        target_arch = "x86_64",
        target_arch = "aarch64",
        target_arch = "loongarch64"
    )
))]
pub(crate) use cpufeatures;

#[cfg(not(all(
    feature = "runtime-cpu-detection",
    any(
        target_arch = "x86",
        target_arch = "x86_64",
        target_arch = "aarch64",
        target_arch = "loongarch64"
    )
)))]
pub(crate) mod cpufeatures {
    #[allow(unused_macros, reason = "XXX")]
    macro_rules! new {
        ($name:ident, $($tt:tt)+) => {
            mod $name {
                #[inline(always)]
                pub(crate) const fn get() -> bool {
                    false
                }
            }
        };
    }

    #[allow(unused_imports, reason = "XXX")]
    pub(crate) use new;
}

/// The hexical characters: "0123456789abcdef" or "0123456789ABCDEF".
pub const DIGITS_LOWER_16: [u8; 16] = *b"0123456789abcdef";

/// The hexical characters: "0123456789abcdef" or "0123456789ABCDEF".
pub const DIGITS_UPPER_16: [u8; 16] = *b"0123456789ABCDEF";

#[allow(unused, reason = "SIMD256")]
pub(crate) const DIGITS_LOWER_32: [u8; 32] = *b"0123456789abcdef0123456789abcdef";

#[allow(unused, reason = "SIMD256")]
pub(crate) const DIGITS_UPPER_32: [u8; 32] = *b"0123456789ABCDEF0123456789ABCDEF";

#[allow(unused, reason = "SIMD512")]
pub(crate) const DIGITS_LOWER_64: [u8; 64] =
    *b"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";

#[allow(unused, reason = "SIMD512")]
pub(crate) const DIGITS_UPPER_64: [u8; 64] =
    *b"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF";

#[inline(always)]
/// The hexical characters: "0123456789abcdef" or "0123456789ABCDEF".
pub(crate) const fn digits16<const UPPER: bool>() -> &'static [u8; 16] {
    if UPPER {
        &DIGITS_UPPER_16
    } else {
        &DIGITS_LOWER_16
    }
}

#[allow(unused, reason = "SIMD256")]
#[inline(always)]
/// The hexical characters: "0123456789abcdef" or "0123456789ABCDEF".
pub(crate) const fn digits32<const UPPER: bool>() -> &'static [u8; 32] {
    if UPPER {
        &DIGITS_UPPER_32
    } else {
        &DIGITS_LOWER_32
    }
}

#[allow(unused, reason = "SIMD512")]
#[inline(always)]
/// The hexical characters: "0123456789abcdef" or "0123456789ABCDEF".
pub(crate) const fn digits64<const UPPER: bool>() -> &'static [u8; 64] {
    if UPPER {
        &DIGITS_UPPER_64
    } else {
        &DIGITS_LOWER_64
    }
}