mod scalar;
#[cfg(target_arch = "x86_64")]
mod sse2;
#[cfg(all(target_arch = "x86_64", target_feature = "ssse3"))]
mod ssse3;
#[inline]
pub(crate) fn hex_encode_u64(value: u64) -> [u8; 16] {
#[cfg(all(target_arch = "x86_64", target_feature = "ssse3"))]
{
ssse3::hex_encode_u64(value)
}
#[cfg(all(target_arch = "x86_64", not(target_feature = "ssse3")))]
{
scalar::hex_encode_u64(value)
}
#[cfg(not(target_arch = "x86_64"))]
{
scalar::hex_encode_u64(value)
}
}
#[inline]
pub(crate) fn hex_encode_u128(hi: u64, lo: u64) -> [u8; 32] {
#[cfg(all(target_arch = "x86_64", target_feature = "ssse3"))]
{
ssse3::hex_encode_u128(hi, lo)
}
#[cfg(all(target_arch = "x86_64", not(target_feature = "ssse3")))]
{
scalar::hex_encode_u128(hi, lo)
}
#[cfg(not(target_arch = "x86_64"))]
{
scalar::hex_encode_u128(hi, lo)
}
}
#[inline]
pub(crate) fn hex_decode_16(bytes: &[u8; 16]) -> Result<u64, usize> {
#[cfg(target_arch = "x86_64")]
{
sse2::hex_decode_16(bytes)
}
#[cfg(not(target_arch = "x86_64"))]
{
scalar::hex_decode_16(bytes)
}
}
#[inline]
pub(crate) fn hex_decode_32(bytes: &[u8; 32]) -> Result<(u64, u64), usize> {
#[cfg(target_arch = "x86_64")]
{
sse2::hex_decode_32(bytes)
}
#[cfg(not(target_arch = "x86_64"))]
{
scalar::hex_decode_32(bytes)
}
}
#[inline]
pub(crate) fn uuid_parse_dashed(bytes: &[u8; 36]) -> Result<(u64, u64), usize> {
#[cfg(all(target_arch = "x86_64", target_feature = "ssse3"))]
{
ssse3::uuid_decode_dashed(bytes)
}
#[cfg(all(target_arch = "x86_64", not(target_feature = "ssse3")))]
{
let mut buf = [0u8; 32];
buf[0..8].copy_from_slice(&bytes[0..8]);
buf[8..12].copy_from_slice(&bytes[9..13]);
buf[12..16].copy_from_slice(&bytes[14..18]);
buf[16..20].copy_from_slice(&bytes[19..23]);
buf[20..32].copy_from_slice(&bytes[24..36]);
hex_decode_32(&buf)
}
#[cfg(not(target_arch = "x86_64"))]
{
let mut buf = [0u8; 32];
buf[0..8].copy_from_slice(&bytes[0..8]);
buf[8..12].copy_from_slice(&bytes[9..13]);
buf[12..16].copy_from_slice(&bytes[14..18]);
buf[16..20].copy_from_slice(&bytes[19..23]);
buf[20..32].copy_from_slice(&bytes[24..36]);
hex_decode_32(&buf)
}
}