libro/lib.rs
1//! # Libro — Cryptographic Audit Chain
2//!
3//! Libro (Italian/Spanish: book, record) provides tamper-proof event logging
4//! with hash-linked entries. Every event is chained to the previous via SHA-256,
5//! making any modification detectable.
6//!
7//! ## Feature Flags
8//!
9//! | Flag | Description |
10//! |------|-------------|
11//! | `sqlite` | SQLite-backed audit store with indexed queries |
12//! | `signing` | Ed25519 digital signatures per entry |
13//! | `streaming` | Real-time pub/sub via majra |
14//!
15//! None are enabled by default.
16//!
17//! ## Modules
18//!
19//! - [`entry`] — Audit entries with hash linking
20//! - [`chain`] — The audit chain: append, verify, query, rotate, retain, paginate
21//! - [`store`] — Persistence backends (memory, file, custom)
22//! - [`file_store`] — Append-only JSON Lines file backend
23//! - [`query`] — Composable query filters
24//! - [`export`] — JSON Lines and CSV export
25//! - [`retention`] — Retention policies
26//! - [`review`] — Structured chain review and summary
27//! - [`merkle`] — Merkle tree for efficient partial verification
28//! - [`verify`] — Chain integrity verification
29//! - [`signing`] — Ed25519 per-entry signatures *(feature: `signing`)*
30//! - [`streaming`] — Real-time pub/sub *(feature: `streaming`)*
31//! - [`sqlite_store`] — SQLite persistence *(feature: `sqlite`)*
32
33pub mod chain;
34pub mod entry;
35pub mod export;
36pub mod file_store;
37pub mod merkle;
38pub mod query;
39pub mod retention;
40pub mod review;
41#[cfg(feature = "signing")]
42pub mod signing;
43#[cfg(feature = "sqlite")]
44pub mod sqlite_store;
45pub mod store;
46#[cfg(feature = "streaming")]
47pub mod streaming;
48pub mod verify;
49
50mod error;
51pub use error::LibroError;
52
53pub use chain::{AuditChain, ChainArchive};
54pub use entry::{AuditEntry, EventSeverity};
55pub use export::{to_csv, to_jsonl};
56pub use file_store::FileStore;
57pub use merkle::{MerkleProof, MerkleTree};
58pub use query::QueryFilter;
59pub use retention::RetentionPolicy;
60pub use review::ChainReview;
61#[cfg(feature = "sqlite")]
62pub use sqlite_store::SqliteStore;
63#[cfg(feature = "streaming")]
64pub use streaming::AuditStream;
65pub use verify::verify_chain;
66
67pub type Result<T> = std::result::Result<T, LibroError>;
68
69#[cfg(test)]
70mod tests;
71
72// Compile-time assertions: all core public types are Send + Sync.
73#[cfg(test)]
74mod assert_traits {
75 fn _assert_send_sync<T: Send + Sync>() {}
76
77 #[test]
78 fn core_types_are_send_sync() {
79 _assert_send_sync::<super::AuditEntry>();
80 _assert_send_sync::<super::AuditChain>();
81 _assert_send_sync::<super::ChainArchive>();
82 _assert_send_sync::<super::QueryFilter>();
83 _assert_send_sync::<super::RetentionPolicy>();
84 _assert_send_sync::<super::ChainReview>();
85 _assert_send_sync::<super::FileStore>();
86 _assert_send_sync::<super::MerkleTree>();
87 _assert_send_sync::<super::MerkleProof>();
88 }
89}