hexz_core/api/manifest.rs
1//! Archive manifest for directory-based archives.
2//!
3//! Stores the mapping of logical file paths to their byte ranges within
4//! the archive's Main stream.
5
6use serde::{Deserialize, Serialize};
7
8/// Metadata for a single file entry in the archive.
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct FileEntry {
11 /// Logical path relative to archive root (e.g. "src/main.rs")
12 pub path: String,
13 /// Logical offset within the `ArchiveStream::Main`
14 pub offset: u64,
15 /// File size in bytes
16 pub size: u64,
17 /// POSIX file mode (permissions)
18 pub mode: u32,
19 /// Last modification time (Unix timestamp)
20 pub mtime: u64,
21}
22
23/// A complete manifest of all files stored in the archive.
24///
25/// Serialized as JSON and stored in the archive's metadata section.
26#[derive(Debug, Clone, Serialize, Deserialize, Default)]
27pub struct ArchiveManifest {
28 /// List of file entries, typically sorted by path
29 pub files: Vec<FileEntry>,
30}
31
32impl ArchiveManifest {
33 /// Finds a file entry by its logical path.
34 pub fn find_file(&self, path: &str) -> Option<&FileEntry> {
35 self.files.iter().find(|f| f.path == path)
36 }
37}