Skip to main content

fcb/
lib.rs

1//! FCB — Forensic Case Bundle codec.
2//!
3//! One Rust crate, two compile targets: native (for the authoring CLI and the
4//! teacher review platform) and WASM (for the in-browser student workbench).
5//! It owns the FCB container format, passphrase-based crypto, compression, the
6//! self-describing evidence model, the embedded task spec, and submission
7//! packaging.
8//!
9//! This module wires the pieces together; the on-the-wire contract lives in
10//! `openspec/specs/fcb-*`.
11//!
12//! # Example
13//!
14//! Pack an evidence case and open it back through the public API:
15//!
16//! ```
17//! use ciborium::value::Value;
18//! use fcb::case::{pack_case, CaseInput, CasePayload};
19//! use fcb::container::BundleKind;
20//! use fcb::evidence::{StreamData, StreamManifest};
21//!
22//! let manifest = vec![StreamManifest {
23//!     id: "s0".into(),
24//!     stream_type: "example.note.v1".into(),
25//!     records: 1,
26//! }];
27//! let payload = CasePayload {
28//!     streams: vec![StreamData {
29//!         id: "s0".into(),
30//!         records: vec![Value::Text("an event".into())],
31//!     }],
32//! };
33//! let input = CaseInput { case_id: "demo".into(), manifest, task: None, payload };
34//!
35//! // pack_case computes the canonical bundle_hash, builds the header meta,
36//! // and seals with a fresh random salt/nonce. The literal "passphrase" here is
37//! // illustration only — never hardcode a passphrase in real code.
38//! let bytes = pack_case(&input, "passphrase")?;
39//!
40//! let (kind, header, _payload) = fcb::bundle::open_bytes(&bytes, "passphrase")?;
41//! assert_eq!(kind, BundleKind::Case);
42//! assert_eq!(header.case_id, "demo");
43//! # Ok::<(), fcb::FcbError>(())
44//! ```
45//!
46//! See [`docs/fcb-integration-guide.md`](https://github.com/triage-lab/fcb-rs/blob/main/docs/fcb-integration-guide.md)
47//! for the full consumer guide.
48
49pub mod binding;
50pub mod bundle;
51pub mod case;
52pub mod cbor;
53pub mod compress;
54pub mod container;
55pub mod crypto;
56pub mod error;
57pub mod evidence;
58pub mod submission;
59pub mod task;
60
61pub use error::{FcbError, Result};
62
63#[cfg(target_arch = "wasm32")]
64mod wasm;