Skip to main content

axhash_core/
lib.rs

1#![cfg_attr(not(any(feature = "std", test)), no_std)]
2mod backend;
3mod constants;
4pub mod hasher;
5mod math;
6mod memory;
7
8pub use hasher::AxHasher;
9pub use hasher::api::{axhash, axhash_of, axhash_of_seeded, axhash_seeded};
10pub use hasher::build::AxBuildHasher;
11
12#[non_exhaustive]
13#[derive(Clone, Copy, Debug, Eq, PartialEq)]
14pub enum RuntimeBackend {
15    Scalar,
16    Aarch64AesNeon,
17    X86_64AesAvx2,
18}
19
20#[inline(always)]
21pub fn runtime_backend() -> RuntimeBackend {
22    match backend::selected_backend() {
23        backend::Backend::Scalar => RuntimeBackend::Scalar,
24        #[cfg(target_arch = "aarch64")]
25        backend::Backend::Aarch64AesNeon => RuntimeBackend::Aarch64AesNeon,
26        #[cfg(target_arch = "x86_64")]
27        backend::Backend::X86_64AesAvx2 => RuntimeBackend::X86_64AesAvx2,
28    }
29}
30
31#[inline(always)]
32pub fn runtime_has_aes() -> bool {
33    runtime_backend() != RuntimeBackend::Scalar
34}
35
36#[cfg(test)]
37mod tests;