lumen/lib.rs
1//! A reference implementation of the LUMEN print file format, version 1.0.
2//!
3//! LUMEN is the Open Resin Alliance's resin (MSLA) print format; the normative
4//! specification lives beside this crate, in `spec/`. This crate is a consumer
5//! of that text, not a substitute for it: where the specification and this code
6//! disagree, the specification wins, and the conformance corpus under
7//! `test-vectors/` is what settles the argument.
8//!
9//! # Shape
10//!
11//! - [`container`] - the file header, chunk directory and trailer.
12//! - [`chunks`] - one codec per chunk type.
13//! - [`json`] - the typed `META`, `PROF` and `LROV` models.
14//! - [`ree`] - run-end encoded layer masks: binary, grayscale and split.
15//! - [`timing`] - the per-layer settings pipeline of section 8.
16//! - [`crypto`] - `AUTH`, the AEAD units, Argon2id and X25519 key wrapping.
17//! - [`validate`] - the checks of section 11, named as the corpus names them.
18//! - [`reader`] - [`reader::LumenFile`], including random access to one layer.
19//! - [`writer`] - [`writer::Encoder`], which produces a conforming file.
20//!
21//! # Reading
22//!
23//! ```no_run
24//! use lumen::{reader::LumenFile, validate::Level};
25//!
26//! let bytes = std::fs::read("print.lumen").unwrap();
27//! let file = LumenFile::open(&bytes, Level::Loose).unwrap();
28//! println!("{} layers", file.layer_count());
29//! let layer = file.layer(0).unwrap();
30//! println!("{:?}", layer.tag);
31//! ```
32//!
33//! # Two tiers
34//!
35//! [`reader::LumenFile`] decodes what a caller asks for and nothing else: a
36//! layer is fetched by index, which decompresses only the `LAYR` chunk that
37//! holds it. A firmware reader can open the file, read `META` and the layer
38//! table, and stream layers through a fixed-size buffer without ever
39//! materializing the whole file. A slicer can instead use [`writer::Encoder`],
40//! which trains the zstd dictionary, frames the chunks and assembles the
41//! directory.
42
43#![forbid(unsafe_code)]
44#![warn(missing_docs)]
45
46pub mod check;
47mod chunkio;
48pub mod chunks;
49pub mod container;
50pub mod crypto;
51pub mod error;
52pub mod io;
53pub mod json;
54pub mod reader;
55pub mod ree;
56pub mod timing;
57pub mod validate;
58pub mod varint;
59pub mod writer;
60
61pub use check::Check;
62pub use container::{ChunkDescriptor, ChunkType, Directory, FileHeader};
63pub use error::{Error, Result};
64pub use json::{Material, Meta, Profile, Sector, Timing};
65pub use reader::LumenFile;
66pub use ree::{DecodedLayer, EncodeMode};
67pub use validate::{Level, Validator};
68pub use writer::Encoder;