export_bundle/lib.rs
1//! Bundle CSV files under a manifest, and check a bundle later.
2//!
3//! A bundle is a directory of CSV files — each rewritten to only the
4//! columns its caller-supplied allow-list declares — beside a
5//! `manifest.json` that records a SHA-256 hash and a row count for every
6//! file. A bundle made here can be checked later, by anyone, with
7//! [`verify`]: re-hash each file, compare, and either every byte is still
8//! what was exported or a specific file is named as different.
9//!
10//! The crate refuses rather than repairs. An input whose header names a
11//! person or a machine stops the whole call. A column not on the
12//! allow-list is dropped and recorded on the manifest, never silently
13//! rewritten. Which columns are safe is the caller's decision, made in the
14//! allow-list; this crate does not know anyone's schema.
15//!
16//! `created_at` is the one wall-clock value, and the caller supplies it:
17//! this crate never reads a clock.
18//!
19//! ```no_run
20//! use std::collections::BTreeMap;
21//! use std::path::Path;
22//!
23//! use export_bundle::{bundle, verify, FileSpec};
24//!
25//! // Synthetic file and column names.
26//! let spec = FileSpec {
27//! path: Path::new("meters.csv").to_owned(),
28//! keep_columns: vec!["id".to_owned(), "watts".to_owned()],
29//! };
30//! let manifest = bundle(
31//! &[spec],
32//! Path::new("bundle"),
33//! BTreeMap::new(),
34//! "2026-01-01T00:00:00Z",
35//! &[],
36//! )
37//! .expect("the bundle writes");
38//! verify(Path::new("bundle")).expect("the bundle verifies");
39//! let _ = manifest;
40//! ```
41//!
42//! The `cli` feature builds a small `export-bundle` binary with the same
43//! two operations, `bundle` and `verify`, using standard-library argument
44//! parsing only.
45
46#![deny(missing_docs)]
47
48mod bundle;
49mod manifest;
50mod verify;
51
52pub use bundle::{bundle, BundleError, FileSpec};
53pub use manifest::{FileEntry, Manifest};
54pub use verify::{verify, VerifyError};