Skip to main content

Crate export_bundle

Crate export_bundle 

Source
Expand description

Bundle CSV files under a manifest, and check a bundle later.

A bundle is a directory of CSV files — each rewritten to only the columns its caller-supplied allow-list declares — beside a manifest.json that records a SHA-256 hash and a row count for every file. A bundle made here can be checked later, by anyone, with verify: re-hash each file, compare, and either every byte is still what was exported or a specific file is named as different.

The crate refuses rather than repairs. An input whose header names a person or a machine stops the whole call. A column not on the allow-list is dropped and recorded on the manifest, never silently rewritten. Which columns are safe is the caller’s decision, made in the allow-list; this crate does not know anyone’s schema.

created_at is the one wall-clock value, and the caller supplies it: this crate never reads a clock.

use std::collections::BTreeMap;
use std::path::Path;

use export_bundle::{bundle, verify, FileSpec};

// Synthetic file and column names.
let spec = FileSpec {
    path: Path::new("meters.csv").to_owned(),
    keep_columns: vec!["id".to_owned(), "watts".to_owned()],
};
let manifest = bundle(
    &[spec],
    Path::new("bundle"),
    BTreeMap::new(),
    "2026-01-01T00:00:00Z",
    &[],
)
.expect("the bundle writes");
verify(Path::new("bundle")).expect("the bundle verifies");
let _ = manifest;

The cli feature builds a small export-bundle binary with the same two operations, bundle and verify, using standard-library argument parsing only.

Structs§

FileEntry
One file in a bundle.
FileSpec
How one file goes into a bundle.
Manifest
What one bundle contains.

Enums§

BundleError
Why a bundle call failed.
VerifyError
Why a bundle did not verify.

Functions§

bundle
Copy the listed files out, filtered, and write the manifest beside them. Action.
verify
Recompute a bundle against its manifest. Action.