1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! lzip — Pure Rust parallel ZIP decompressor.
//!
//! Architecture:
//! Parse the ZIP Central Directory (at file tail) → Vec<EntryLocation>.
//! Dispatch every file entry to a rayon worker that DEFLATE-decodes it
//! independently. Results reassembled in Central Directory order.
//!
//! In-memory slice (< 10 MB): all entries decoded in one parallel pass.
//! Streaming (Read + Seek): Central Directory parsed by seeking to tail;
//! entries read and decoded in parallel batches of 64 — the file is
//! never fully loaded into RAM.
pub use ;
pub use StreamingZipRead;
/// **Introspection / emit marker** — record one functional-status row for the
/// nornir test matrix. Wraps `nornir_testmatrix::functional_status` behind the
/// `testmatrix` feature (a compiled-out `#[inline]` no-op otherwise, with no
/// nornir dep in the default build). Mirrors the korp-collectors reference
/// wiring so `nornir test --features testmatrix` SEES the lzip CLI.
/// Files below this threshold are decompressed in a single parallel pass.
/// Files at or above use batched parallel decode.
const SMALL_FILE_THRESHOLD: usize = 10 * 1024 * 1024; // 10 MB
// ── Parallelism ───────────────────────────────────────────────────────────────
//
// Per-entry / per-segment DEFLATE decode fans out through the constellation's
// ONE shared no-barrier engine — `gatling::gatling_forkjoin::gatling_for_each`
// (N workers draining a shared atomic cursor, one per core). The old private
// rayon `ThreadPool` (`thread_pool()` / `LZIP_THREADS`) is gone; rayon is no
// longer a dependency.
// ── Public API ────────────────────────────────────────────────────────────────
/// Decompress all file entries in a ZIP byte slice.
///
/// For small slices (< 10 MB) decodes all entries in one parallel pass.
/// For larger slices uses the streaming reader with a `Cursor` wrapper.
/// Returns entries in Central Directory order; directory entries are excluded.
/// Decompress only entries whose name contains `needle`.
///
/// Filters at the central directory level — non-matching entries are never
/// read or decompressed. Fast prefix/suffix/substring match.
///
/// ```no_run
/// // Extract only matching files from a ZIP
/// let data = std::fs::read("archive.zip").unwrap();
/// let entries = lzip_parallel::decompress_zip_filter(&data, "pom.xml").unwrap();
/// ```
/// Decompress only entries whose name exactly matches one of `names`.
///
/// Filters at the central directory level — non-matching entries are never
/// read or decompressed. Use this when you need specific files from a wheel/zip.
///
/// ```no_run
/// let data = std::fs::read("pkg.whl").unwrap();
/// let entries = lzip_parallel::decompress_zip_filter_set(&data, &["METADATA", "RECORD"]).unwrap();
/// ```
/// Decompress only entries whose name ends with one of the given `suffixes`.
///
/// Useful for extracting all files of a certain type (e.g. all `.py` files from a wheel).
///
/// ```no_run
/// let data = std::fs::read("pkg.whl").unwrap();
/// let entries = lzip_parallel::decompress_zip_filter_suffixes(&data, &[".py", ".pyi"]).unwrap();
/// ```
/// Decompress all file entries from any `Read + Seek` source without loading
/// the full file into memory.
///
/// Parses the Central Directory by seeking to the file tail, then reads and
/// decodes entries in parallel batches of 64. Directory entries are excluded.
/// Entries are returned sorted by their position in the file.