xue/encode/mod.rs
1//! An experimental native encoder for the Xue v1 bundle format.
2//!
3//! The production encoder is Python (`xue/` at the repository root),
4//! orchestrating GDAL and zstd as CLI subprocesses. This module is the
5//! same pipeline in Rust with the external tools linked in process instead:
6//!
7//! * **GDAL** through `gdal-sys` (georust) replaces `gdalinfo -json` and
8//! `gdal_translate -of ENVI` — a production GFS run wrote and re-read
9//! several gigabytes of intermediate ENVI files per build, which the
10//! Python-side profiling identified as the remaining wall.
11//! * **grib-rs** replaces the hand-rolled GRIB2 header index that locates each
12//! variable's band.
13//! * **zstd** is linked rather than piped through the CLI.
14//! * The decoder in this same crate is the read-back verifier, so every bundle
15//! the encoder writes is decoded, and every store's documents and shard
16//! indexes parsed, by the code the browser and the API run.
17//!
18//! Scope is `convert-bin`: gridded input to Zarr stores (`zarrstore`) and,
19//! when asked for, `.xue` bundles, reduced-resolution variants, posters and
20//! the manifest, and `columns`, the column store cut from a finished run's
21//! map stores. Fetching, the showcase driver and the optional
22//! H.264 companion artifacts stay in Python.
23//!
24//! It is behind the off-by-default `encoder` feature: it links GDAL, which the
25//! decoder does not, and nothing that only decodes should have to find a GDAL
26//! to build. `docs/bundle.md`, `docs/zarr-profile.md` and `docs/format.md` are
27//! the normative specs for everything written here, and `xuebuild/binconvert.py` is the reference the outputs are diffed
28//! against.
29
30/// An `INFO` line on stderr when the build asked for a verbose log.
31macro_rules! log {
32 ($options:expr, $($argument:tt)*) => {
33 if $options.verbose {
34 eprintln!("INFO {}", format!($($argument)*));
35 }
36 };
37}
38
39// Only what something outside this crate actually links against is public:
40// `xue-py` imports columns, convert, gdalio, grid, poster, quantize, registry and
41// temporal, and the xue-encode binary — a separate crate against the lib, not
42// part of it — adds errors. The rest is pipeline interior, crate-private so
43// it stays free to move; what used to be tested through `tests/encoder.rs`
44// is tested from inside those modules instead.
45pub(crate) mod binformat;
46pub mod columns;
47pub mod convert;
48pub(crate) mod derive;
49pub(crate) mod discover;
50pub mod errors;
51pub mod gdalio;
52pub(crate) mod gribindex;
53pub(crate) mod gribpng;
54pub mod grid;
55pub(crate) mod inspect;
56pub(crate) mod ladder;
57pub(crate) mod manifest;
58pub(crate) mod metadata;
59pub(crate) mod model;
60pub(crate) mod observation;
61pub(crate) mod parallel;
62pub mod poster;
63pub(crate) mod pyjson;
64pub mod quantize;
65pub mod registry;
66pub(crate) mod report;
67pub(crate) mod reproject;
68pub(crate) mod sources;
69pub(crate) mod spool;
70pub mod temporal;
71pub(crate) mod units;
72pub(crate) mod variables;
73pub mod zarrstore;
74
75pub use convert::{convert_bin, ConvertOptions};
76pub use errors::{EncodeError, Result};
77pub use registry::Registry;