euv_cli/builder/archive/struct.rs
1use super::*;
2
3/// Single verified asset record inside `euv-release.json`.
4#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
5pub struct ReleaseManifestFileEntry {
6 /// Forward-slash relative path from the distribution root.
7 pub(crate) path: String,
8 /// Lowercase hexadecimal SHA-256 digest of the file bytes.
9 pub(crate) sha256: String,
10 /// Exact byte length of the file on disk.
11 #[get(type(copy))]
12 pub(crate) size: u64,
13}
14
15/// Deterministic SHA-256 inventory manifest written to `euv-release.json`.
16#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
17pub struct ReleaseAssetManifest {
18 /// Manifest format version (always `1`).
19 #[get(type(copy))]
20 pub(crate) format: u32,
21 /// Numeric semantic version (`MAJOR.MINOR.PATCH`).
22 pub(crate) version: String,
23 /// Lexicographically sorted list of verified release files.
24 pub(crate) files: Vec<ReleaseManifestFileEntry>,
25}
26
27/// Binary scan report proving whether dev-only AI schema markers leaked into an artifact.
28#[derive(Clone, Data, Debug, Deserialize, Eq, New, PartialEq, Serialize)]
29pub struct AiSchemaScanReport {
30 /// Filesystem path of the scanned artifact.
31 pub(crate) path: PathBuf,
32 /// Number of `euv.ai.schema.v1` occurrences found.
33 #[get(type(copy))]
34 pub(crate) v1_matches: usize,
35 /// Number of `euv.ai.schema.v2` occurrences found.
36 #[get(type(copy))]
37 pub(crate) v2_matches: usize,
38 /// Combined count of v1 and v2 schema marker hits.
39 #[get(type(copy))]
40 pub(crate) total_matches: usize,
41}
42
43/// Single file entry to write into a pure-Rust PKZIP archive.
44#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
45pub struct ZipEntryInput {
46 /// Forward-slash archive-relative path (e.g. `classes.dex` or `lib/arm64-v8a/lib.so`).
47 pub(crate) archive_path: String,
48 /// Raw uncompressed entry payload bytes.
49 pub(crate) data: Vec<u8>,
50 /// When `true`, forces PKZIP method 0 (STORED / uncompressed); otherwise uses DEFLATE if smaller.
51 #[get(type(copy))]
52 pub(crate) stored: bool,
53 /// UNIX permission bits stored in external file attributes (e.g. `0o644` or `0o755`).
54 #[get(type(copy))]
55 pub(crate) unix_mode: u32,
56}
57
58/// Single file or directory entry to write into a pure-Rust `.tar.gz` archive.
59#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
60pub struct TarEntryInput {
61 /// Forward-slash archive-relative path.
62 pub(crate) archive_path: String,
63 /// Raw file payload bytes (empty for directories).
64 pub(crate) data: Vec<u8>,
65 /// UNIX permission bits (e.g. `0o644` or `0o755`).
66 #[get(type(copy))]
67 pub(crate) unix_mode: u32,
68 /// Whether this entry represents a directory record.
69 #[get(type(copy))]
70 pub(crate) is_dir: bool,
71}
72
73/// Internal LSB-first bit reader used by the pure-Rust RFC 1951 DEFLATE decompressor.
74pub(crate) struct DeflateBitReader<'a> {
75 /// Input byte slice being decoded.
76 pub(crate) bytes: &'a [u8],
77 /// Current byte index inside `bytes`.
78 pub(crate) byte_pos: usize,
79 /// Buffered bits pending consumption.
80 pub(crate) bit_buf: u64,
81 /// Number of valid low bits currently inside `bit_buf`.
82 pub(crate) bit_count: u32,
83}
84
85/// Internal LSB-first bit writer used by the pure-Rust RFC 1951 DEFLATE compressor.
86pub(crate) struct DeflateBitWriter {
87 /// Output encoded bytes.
88 pub(crate) out: Vec<u8>,
89 /// Buffered bits pending byte flush.
90 pub(crate) bit_buf: u64,
91 /// Number of buffered low bits in `bit_buf`.
92 pub(crate) bit_count: u32,
93}
94
95/// Canonical Huffman decoding table constructed from code bit lengths.
96pub(crate) struct HuffmanDecoder {
97 /// Number of symbols assigned each bit length `1..=15`.
98 pub(crate) counts: [u16; DEFLATE_MAX_BITS + 1],
99 /// Symbols sorted canonically by `(bit_length, symbol)`.
100 pub(crate) symbols: Vec<u16>,
101}
102
103/// Internal metadata record accumulated while writing PKZIP entries for the Central Directory.
104pub(crate) struct ZipCentralRecord {
105 /// UTF-8 archive entry name bytes.
106 pub(crate) name_bytes: Vec<u8>,
107 /// Compression method written to headers (`0` stored or `8` deflate).
108 pub(crate) method: u16,
109 /// General-purpose bit flags.
110 pub(crate) flags: u16,
111 /// CRC-32 of the uncompressed data.
112 pub(crate) crc32: u32,
113 /// Compressed byte size.
114 pub(crate) compressed_size: u32,
115 /// Uncompressed byte size.
116 pub(crate) uncompressed_size: u32,
117 /// Byte offset of the Local File Header within the archive.
118 pub(crate) local_offset: u32,
119 /// External file attributes (UNIX mode in upper 16 bits).
120 pub(crate) external_attrs: u32,
121}
122
123/// Preserved raw entry extracted from an existing ZIP archive before appending new entries.
124pub(crate) struct ExistingZipRawEntry {
125 /// UTF-8 archive entry name.
126 pub(crate) name: String,
127 /// Original compression method.
128 pub(crate) method: u16,
129 /// Original general-purpose bit flags.
130 pub(crate) flags: u16,
131 /// Original CRC-32 checksum.
132 pub(crate) crc32: u32,
133 /// Original compressed payload bytes.
134 pub(crate) compressed_data: Vec<u8>,
135 /// Original uncompressed byte length.
136 pub(crate) uncompressed_size: u32,
137 /// Original external file attributes.
138 pub(crate) external_attrs: u32,
139}