Skip to main content

pith_digest/
lib.rs

1//! The shared vocabulary of the `pith` suite: the one error type, the
2//! fixed-width digest value, the Hamming distance between digests, and
3//! the closed sets of names that appear in on-disk records. Also the
4//! computational primitives every modality crate shares: SHA-256, the
5//! checksums (CRC-32, Adler-32, FNV-1a 64), splitmix64 and the bit
6//! reader.
7//!
8//! The foundation crate of the zero-dependency `pith` suite. Every other
9//! crate builds on these types and nothing builds beneath them: this
10//! crate has an empty `[dependencies]` table, enforced by
11//! `scripts/check-zero-deps.py`.
12//!
13//! The crate is `core`-only in its library shape: no filesystem,
14//! network, clock or environment, and no code path allocates. The
15//! `std` feature (on by default) links `std` so the `cdylib` the
16//! language SDKs bind through carries a panic handler; the library
17//! surface itself stays `core`-only either way.
18
19#![cfg_attr(not(feature = "std"), no_std)]
20#![deny(unsafe_code)]
21#![deny(missing_docs)]
22
23mod bitreader;
24mod checksums;
25mod digest;
26mod distance;
27mod error;
28mod names;
29mod sha1;
30mod sha256;
31mod sha512;
32mod splitmix64;
33
34pub mod base64;
35pub mod ffi;
36pub mod xxh64;
37
38mod crc32c;
39mod hmac;
40mod murmur3;
41mod xoshiro;
42
43// The Java SDK's native-method surface: `Java_hash_pith_digest_*`
44// exports that forward to the C ABI above. Compiled out of the
45// unit-test build (the `#[no_mangle]` exports would collide with the
46// test binary's copies) and out of `--no-default-features` builds (the
47// glue needs `std` allocations); `tests/java_ffi.rs` covers the glue
48// against a synthetic JNI environment instead. Private module: the JVM
49// links the exports by symbol name, so nothing here needs to be
50// publicly nameable in Rust.
51#[cfg(all(not(test), feature = "std"))]
52mod ffi_jni;
53
54pub use crate::base64::{base64_decode, base64_encode};
55pub use crate::bitreader::BitReader;
56pub use crate::checksums::{adler32, crc32, fnv1a64};
57pub use crate::crc32c::crc32c;
58pub use crate::digest::{Digest, Read};
59pub use crate::distance::hamming;
60pub use crate::error::{Error, Result};
61pub use crate::hmac::{hmac_sha1, hmac_sha256, hmac_sha512};
62pub use crate::murmur3::murmur3_x64_128;
63pub use crate::names::{Algorithm, Format};
64pub use crate::sha1::sha1;
65pub use crate::sha256::sha256;
66pub use crate::sha512::sha512;
67pub use crate::splitmix64::SplitMix64;
68pub use crate::xoshiro::Xoshiro256StarStar;
69pub use crate::xxh64::xxh64;