Skip to main content

znippy_common/
lib.rs

1extern crate core;
2
3/// Re-export arrow so plugins implement `schema_fields()` against the exact same arrow
4/// version as the core trait, avoiding type-mismatch across crate boundaries.
5pub use arrow;
6
7/// Re-export blake3 for the same reason arrow is re-exported: the archive's
8/// per-chunk `checksum` column is blake3 over the chunk's bytes, and a writer
9/// living in another crate (`znippy-plugin-git`'s generation-0 seal) must fill
10/// that column with the **same** implementation the reader checks it against.
11/// Pinning it here rather than re-declaring the dependency there is what makes
12/// a version skew between the two impossible rather than merely unlikely.
13pub use blake3;
14
15/// **Introspection / emit marker** — record one functional-status row for the
16/// nornir test matrix. Wraps `nornir_testmatrix::functional_status` behind the
17/// `testmatrix` feature (a compiled-out `#[inline]` no-op otherwise, with no
18/// nornir dep in the default build). `component` is the reporting surface (e.g.
19/// `"znippy-common/decompress"`), `check` what it verified, `ok` the REAL
20/// verdict, `detail` a short measured note. The decompress path + the Magazine
21/// slot-lifecycle self-tests call this so `nornir test --features testmatrix`
22/// SEES each surface's health. Defined only under the feature — every call site
23/// is itself `#[cfg(feature = "testmatrix")]` (so the detail-string work is
24/// stripped in the default build, per the nornir-testmatrix doctrine), so there
25/// is no non-feature caller to no-op for.
26#[cfg(feature = "testmatrix")]
27#[inline]
28pub(crate) fn functional_status(component: &str, check: &str, ok: bool, detail: &str) {
29    nornir_testmatrix::functional_status(component, check, ok, detail);
30}
31
32pub mod codec;
33pub mod common_config;
34/// Host memory and CPU facts read straight from `/proc` and `/sys/fs/cgroup`.
35/// Replaces the `sysinfo` runtime dependency, which reached this crate's whole
36/// consumer set — and, via its `multithread` feature, put `rayon` in it.
37pub mod hostinfo;
38pub mod index;
39/// Whether a payload is already compressed, and so should be stored raw.
40/// Resolution order: an explicit caller hint, then the extension table, then a
41/// magic-byte probe over the head of the real bytes.
42pub mod precompressed;
43pub mod archive;
44pub mod meta_sink;
45pub mod meta_sink_append;
46/// Searchable archive metadata: the `META_MODULE` sub-index, its typed key/value
47/// model, and the query API — "which entries carry key X" answered from an
48/// index, at a cost set by the metadata, not by the payload.
49pub mod meta_index;
50
51pub mod slotpool;
52
53pub mod meta;
54pub use meta::{BlobMeta, ChunkMeta, FileMeta};
55
56/// Detached, streaming CMS provenance signatures (per-artifact + per-archive).
57/// Off by default; default builds and the on-disk format are byte-unchanged.
58#[cfg(feature = "sign")]
59pub mod sign;
60
61pub mod plugin;
62pub mod plugins;
63pub mod views;
64
65pub mod decompress;
66
67/// The DYNAMIC half of the archive: append at O(1), seal once. See `hot`.
68pub mod hot;
69
70pub use meta_sink_append::{
71    compact_archive, read_delta_map, supersede_as_delta, CompactReport, SupersedeOutcome,
72    MAX_GENERATION_CHAIN,
73};
74pub use archive::{
75    BaseResolve, ChunkSplitter, DeltaSplitter, Entry, ReconstructCtx, RegionDeltaSplitter,
76    Splitter, StoredUnit, UnitPayload, ZnippyArchive, ZnippyReader,
77};
78pub use views::{
79    CondaPackage, CondaView, GemPackage, GemView, MavenPackage, MavenView, NpmPackage, NpmView,
80    PythonKind, PythonPackage, PythonView, RustPackage, RustView, CONDA_PKG_TYPE, GEM_PKG_TYPE,
81    MAVEN_PKG_TYPE, NPM_PKG_TYPE, PYTHON_PKG_TYPE, RUST_PKG_TYPE,
82};
83pub use decompress::{decompress_archive, decompress_archive_filtered, get_file};
84pub use meta_sink::{
85    ArchiveMetaSink, ArrowIpcSink, GroupKey, LookupView, MetaSinkFactory, ReservedPayload,
86    ReservedSection, ReservedSectionBuilder,
87};
88pub use hot::{HotAppendReport, HotArchive, HotSealReport, seal_hot};
89pub use meta_sink_append::{
90    append_files_with_policy,
91    AppendReport, ArrowIpcSinkAppend, append_files, append_files_with_meta, base_batch_from_rows,
92    create_archive, create_archive_to_vec, create_archive_with_meta,
93};
94/// Searchable metadata: seal typed key/value facts with an archive and answer
95/// "which entries carry key X" from the index alone. `ArchiveMeta::NoMetadata`
96/// is a distinct state from a present-but-empty index — see `meta_index`.
97pub use meta_index::{
98    ArchiveMeta, MetaEntry, MetaIndex, MetaSearch, MetaTable, MetaValue, read_archive_meta,
99};
100
101pub use precompressed::{ContentHint, SkipPolicy, SNIFF_PREFIX_LEN, is_zlib_stream, looks_compressed};
102
103pub use index::{
104    ArchiveReader,
105    ArtifactMeta, ChunkLoc, IndexFilter, VerifyReport, ZNIPPY_INDEX_SCHEMA,
106    MULTI_INDEX_MAGIC, ManifestEntry, IndexFooter,
107    META_MODULE, build_arrow_metadata_for_config, build_metadata_batch, data_subindex_schema,
108    extract_config_from_arrow_metadata, get_all_files_meta, get_files_meta_with_prefix,
109    interpret_footer,
110    is_probably_compressed, is_reserved_module, list_archive_contents, locate_file,
111    read_manifest_bytes, read_reserved_section_bytes, read_znippy_full_manifest, read_znippy_index,
112    read_znippy_index_filtered, read_znippy_manifest,
113    should_skip_compression, verify_archive_integrity, write_manifest_bytes,
114    znippy_index_schema, SIGN_ARCHIVE_MODULE, SIGN_ARTIFACTS_MODULE,
115    GUNNAR_GRAPH_MODULE, GUNNAR_OID_MODULE, GUNNAR_REACH_MODULE, GUNNAR_REFS_MODULE,
116    GUNNAR_SECRETS_MODULE, LOOKUP_MODULE,
117    RESERVED_MODULES, RESERVED_PKG_TYPE, TRIE_MODULE, lookup_schema,
118};
119
120#[derive(Debug)]
121pub struct CompressionReport {
122    pub total_files: u64,
123    pub compressed_files: u64,
124    pub uncompressed_files: u64,
125    pub total_dirs: u64,
126    pub total_bytes_in: u64,
127    pub total_bytes_out: u64,
128    pub compressed_bytes: u64,
129    pub uncompressed_bytes: u64,
130    pub compression_ratio: f32,
131    pub chunks: u64,
132    /// Files that the walk enumerated but whose bytes never reached a committed
133    /// chunk (open/read failed and the file was silently dropped). Derived as
134    /// `total_files - (compressed_files + uncompressed_files)`. A green compress
135    /// surface REQUIRES `files_failed == 0` — see `compress_reporting`.
136    pub files_failed: u64,
137}