use autocxx::prelude::*;
include_cpp! {
#include "pthash.hpp"
generate_pod!("pthash::build_timings")
generate_pod!("pthash::hash64")
generate_pod!("pthash::hash128")
}
pub(crate) use ffi::pthash::build_timings;
pub use ffi::pthash::{hash128, hash64};
impl From<u64> for hash64 {
fn from(value: u64) -> Self {
moveit! {
let h = unsafe { hash64::new1(value) };
};
autocxx::moveit::MoveRef::into_inner(std::pin::Pin::into_inner(h))
}
}
impl From<u128> for hash128 {
fn from(value: u128) -> Self {
let high = (value >> 64) as u64;
let low = (value & 0xFFFFFFFF) as u64;
(high, low).into()
}
}
impl From<(u64, u64)> for hash128 {
fn from(value: (u64, u64)) -> Self {
let (high, low) = value;
moveit! {
let h = unsafe { hash128::new1(high, low) };
};
autocxx::moveit::MoveRef::into_inner(std::pin::Pin::into_inner(h))
}
}