Skip to main content

engenho_substrate_core/
lib.rs

1//! # engenho-substrate-core
2//!
3//! The tokio-free core of engenho's substrate. Everything here is plain
4//! data, pure functions and `std` I/O; no async runtime is a dependency of
5//! this crate, so no module can reach one (the manifest is the seal, and
6//! `tests/tokio_free.rs` pins it).
7//!
8//! The substrate is carved in three by what is reachable:
9//!
10//! | Crate | Holds | Who may depend on it |
11//! |---|---|---|
12//! | `engenho-substrate-core` (this crate) | the eleven modules below | anyone |
13//! | `engenho-substrate` (the leaf) | every module a shipped crate references; re-exports this crate whole | shipped crates |
14//! | `engenho-substrate-incubator` | modules no shipped crate references | tests and drafts only |
15//!
16//! Every path under `engenho_substrate::` that named one of these modules
17//! still resolves: the leaf re-exports this crate with a glob, macros
18//! included.
19//!
20//! ## Modules
21//!
22//!   * [`closed_enum`] — `closed_enum!`, a fieldless enum and its `ALL`
23//!     (and optionally its `name()`) generated from one variant list
24//!   * [`error_kind`] — `ErrorKind` + `impl_error_kind!`, the stable tag
25//!     every typed error reports
26//!   * [`named`] — `Named` + `define_named!` / `impl_named_field!`
27//!   * [`hex`] / [`hash_newtype`] — hex encoding and the
28//!     `define_hash_newtype!` BLAKE3 newtype surface
29//!   * [`fingerprint`] — `Fingerprint` + `impl_fingerprint!`
30//!   * [`atomic_write`] — fsync-anchored tmp+rename atomic write
31//!   * [`magic_blob`] — versioned magic header + BLAKE3-hashed payload
32//!   * [`risca`] — `Risca<T>` redaction + `assert_risca_no_leak!`
33//!   * [`relogio`] — `Clock`, `Instant` and the wall/frozen/HLC clocks
34//!   * [`host_root`] — `HostRoot`, the root every absolute host path
35//!     resolves under (`/` on a node, a temporary directory in tests)
36
37#![warn(clippy::pedantic)]
38#![warn(missing_docs)]
39#![allow(clippy::module_name_repetitions)]
40
41pub mod atomic_write;
42pub mod closed_enum;
43pub mod error_kind;
44pub mod fingerprint;
45pub mod hash_newtype;
46pub mod hex;
47pub mod host_root;
48pub mod magic_blob;
49pub mod named;
50pub mod relogio;
51pub mod risca;
52
53pub use atomic_write::{
54    AtomicWriteError, TempPath, WriteOnce, write_atomic, write_atomic_mode, write_new_atomic_mode,
55};
56pub use error_kind::ErrorKind;
57pub use fingerprint::{Fingerprint, fingerprint_blake3};
58pub use hash_newtype::{
59    HashNewtypeError, hex_full, hex_prefix, parse_hex_32_padded, parse_hex_32_strict,
60};
61pub use hex::{Hex, hex_encode};
62pub use host_root::HostRoot;
63pub use magic_blob::{MagicBlob, MagicBlobError};
64pub use named::Named;
65pub use relogio::{Clock, FrozenClock, HlcClock, Instant, LogicalClock, WallClock};
66pub use risca::{REDACTED, Redact, Risca, redact_credit_card, redact_email, redact_token};