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