Skip to main content

git_internal/internal/metadata/
entry_meta.rs

1//! Metadata container that accompanies pack entries to track file paths, on-disk offsets, CRC32
2//! checksums, and delta flags so downstream encoders/decoders can enrich responses.
3
4/// Metadata about a pack entry.
5#[derive(Debug, Clone, Default)]
6pub struct EntryMeta {
7    pub file_path: Option<String>,
8
9    pub pack_id: Option<String>,
10
11    /// Offset within the pack file
12    pub pack_offset: Option<usize>,
13    /// CRC32 checksum of the compressed object data (including header)
14    pub crc32: Option<u32>,
15
16    pub is_delta: Option<bool>,
17}
18
19impl EntryMeta {
20    /// Create a new empty metadata container.
21    pub fn new() -> Self {
22        Self::default()
23    }
24
25    /// Set the file path associated with this entry.
26    pub fn set_pack_id(&mut self, id: impl Into<String>) -> &mut Self {
27        self.pack_id = Some(id.into());
28        self
29    }
30
31    /// Set the file path associated with this entry.
32    pub fn set_crc32(&mut self, crc32: u32) -> &mut Self {
33        self.crc32 = Some(crc32);
34        self
35    }
36}