ubl_ledger/
lib.rs

1#![forbid(unsafe_code)]
2#![deny(missing_docs)]
3#![allow(clippy::multiple_crate_versions)]
4//! UBL — Universal Business Ledger (NDJSON)
5//!
6//! This crate provides:
7//! - **Canonical bytes**: all intents serialized via `json_atomic::canonize`
8//! - **Stable CID**: `Cid32 = BLAKE3(canonical_bytes)`
9//! - **Optional signing**: domain `UBL:LEDGER:v1` + CID, via `atomic-crypto`
10//! - **Append-only NDJSON**: writers and readers with verification
11//!
12//! ## Modules
13//!
14//! - [`ledger`]: Simplified API with `LedgerEntry`, `SimpleLedgerWriter`, `SimpleLedgerReader`
15//! - [`writer`], [`reader`]: Full-featured writer/reader with rotation and WAL
16//! - [`event`]: Event model
17//! - [`verify`]: Verification helpers
18
19/// Signing domain for UBL ledger entries.
20pub const UBL_DOMAIN_SIGN: &[u8] = b"UBL:LEDGER:v1";
21
22/// UBL event model.
23pub mod event;
24/// Simplified ledger API with canonical bytes and optional signing.
25pub mod ledger;
26/// Path helpers for UBL layout.
27pub mod paths;
28/// File reader utilities.
29pub mod reader;
30/// Verification helpers.
31pub mod verify;
32/// Synchronous writer.
33pub mod writer;
34#[cfg(feature = "async")]
35/// Async writer.
36pub mod writer_async;
37
38pub use ledger::{
39    AppendResult, FsyncPolicy, LedgerEntry, LedgerError, LedgerWriter, RotatePolicy,
40    SimpleLedgerIter, SimpleLedgerReader, SimpleLedgerWriter,
41};
42pub use reader::{tail_file, UblIter, UblReader};
43pub use writer::{Rotation, UblWriter};
44#[cfg(feature = "async")]
45pub use writer_async::{AsyncConfig, UblWriterAsync};