xue/lib.rs
1// docs.rs passes --cfg docsrs (see Cargo.toml), which is the only build
2// where `doc(cfg(...))` is available — it is a nightly rustdoc feature.
3#![cfg_attr(docsrs, feature(doc_cfg))]
4
5//! Xue bundle parser and frame decoder.
6//!
7//! The contract is defined in `docs/bundle.md` (metadata, codebooks),
8//! `docs/zarr-profile.md` (stores) and `docs/format.md` (the legacy
9//! container), mirrored by the Python reference implementation in
10//! `xuebuild/`. Every
11//! integer computation on untrusted input uses checked arithmetic, and no
12//! allocation is sized from a file value before it is validated against the
13//! metadata grid and the file length.
14//!
15//! Both container versions are read. In v1 a payload is one whole plane of
16//! one frame; in v2 it is a chunk — one spatial tile of one temporal group
17//! for one variable — which is what lets a reader fetch only the tiles a
18//! viewport covers ([`Bundle::decode_frame_tiles`]) and read one cell's
19//! whole series at one chunk per group ([`Bundle::decode_series`]).
20//!
21//! Two readers share the same structural validation and decode logic:
22//! [`Bundle`] opens a complete file, while [`StreamingBundle`] opens only the
23//! structural prefix (header + metadata + index) and accepts payload bytes
24//! incrementally as HTTP range responses arrive.
25//!
26//! The crate is arranged as the format in the middle and the two directions
27//! around it:
28//!
29//! * [`mod@format`] — the container's byte layout, and nothing else: the
30//! constants, the enums, and the pack/unpack pair for each structure. Both
31//! directions go through it, so a field cannot drift between them.
32//! * [`decode`] — reading, re-exported here. Links nothing, compiles to wasm.
33//! * [`mod@level3`] — NEXRAD Level 3 N0B / N0G sweeps, a port of the
34//! Python reader the polar store is built from, so the browser can read a
35//! live site's sweeps straight from the public bucket.
36//! * [`mod@network`] — the Zarr profile's network store: one value per
37//! river reach per frame, read IO-free like [`mod@zarr`].
38//! * [`mod@column`] — the Zarr profile's column store: a run's codes cut so
39//! one cell's whole column over the whole axis is one inner chunk, read
40//! IO-free too.
41//! * [`mod@projection`] — the grid geometry both directions share: the
42//! Lambert conformal projection and true Gaussian latitudes.
43//! * `encode` — the native encoder, behind the off-by-default `encoder`
44//! feature because it links GDAL. Not a link: on a decode-only build
45//! the module does not exist, so linking it would dangle there.
46
47pub mod column;
48pub mod decode;
49pub mod format;
50pub mod level3;
51pub mod network;
52pub mod projection;
53pub mod zarr;
54
55#[cfg(test)]
56mod schematie;
57
58pub use decode::{decode_chunk, decode_chunk_u16, Bundle, StreamingBundle};
59pub use format::{
60 align8, ChunkEntry, Compression, DecodeError, FixedHeader, FrameRequest, GroupEntry,
61 IndexHeader, IndexHeaderV2, PlaneEntry, Predictor, TileGeometry, TileRect, VariableEntry,
62 CHUNK_ENTRY_SIZE, ENTRY_SIZE, FLAG_ZSTD_CHECKSUM, GROUP_ENTRY_SIZE, HEADER_SIZE, HOUR_SECONDS,
63 INDEX_HEADER_SIZE, INDEX_HEADER_SIZE_V2, INDEX_MAGIC, INDEX_MAGIC_V2, INDEX_VERSION,
64 INDEX_VERSION_V2, MAGIC, MAX_PLANE_LENGTH, NO_DEPENDENCY, VARIABLE_ENTRY_SIZE, VERSION,
65 VERSION_V2,
66};
67pub use level3::{read_level3, Level3Sweep, LEVEL3_BEAMS};
68
69// The experimental native encoder, behind an off-by-default feature because it
70// links GDAL. Everything else in this crate is the decoder, which links nothing.
71#[cfg(feature = "encoder")]
72#[cfg_attr(docsrs, doc(cfg(feature = "encoder")))]
73pub mod encode;