pub struct PackManager { /* private fields */ }Expand description
Format-only coordinator for loaded pack and index files.
Object-domain indexes belong in a wrapper owned by the consuming crate.
Implementations§
Source§impl PackManager
impl PackManager
pub fn new(packs_dir: PathBuf) -> PackManager
pub fn reload(&mut self) -> Result<(), HeddleError>
Sourcepub fn add_pack(
&mut self,
pack_path: PathBuf,
index_path: PathBuf,
) -> Result<(), HeddleError>
pub fn add_pack( &mut self, pack_path: PathBuf, index_path: PathBuf, ) -> Result<(), HeddleError>
Add a complete pack/index pair to the in-memory format index.
Sourcepub fn needs_reload(&self) -> Result<bool, HeddleError>
pub fn needs_reload(&self) -> Result<bool, HeddleError>
Check whether the immutable pack set on disk differs from this snapshot.
Comparing only counts misses the decisive repack transition (one old
→ one replacement). Exact path comparison lets another FsStore
recover after an atomic cutover even when cardinality is unchanged.
Half-installed packs remain filtered by discover_pack_paths.
Sourcepub fn reload_if_stale(&mut self) -> Result<bool, HeddleError>
pub fn reload_if_stale(&mut self) -> Result<bool, HeddleError>
Reload the pack list when the immutable pack set changed on disk.
Catches the multi-instance case: two FsStores back the same
shared object dir (typical for lightweight thread worktrees,
where the worktree’s repo opens its own store but points at
the main repo’s .heddle/). When the worktree’s store installs
a new pack, the main repo’s already-open pack_manager
doesn’t know about it; without this get_blob/has_blob
from the main repo would surface “object not found”.
pub fn get_object( &self, id: &PackObjectId, ) -> Result<Option<(ObjectType, Vec<u8>)>, HeddleError>
Sourcepub fn object_read_tier(
&self,
id: &PackObjectId,
) -> Result<Option<PackReadTier>, HeddleError>
pub fn object_read_tier( &self, id: &PackObjectId, ) -> Result<Option<PackReadTier>, HeddleError>
Return the physical tier that will serve id.
When both layouts contain the same immutable object, lookup always selects the hot random-access record before a solid frame.
Sourcepub fn get_object_from_pack(
&self,
pack_path: &Path,
id: &PackObjectId,
) -> Result<Option<(ObjectType, Vec<u8>)>, HeddleError>
pub fn get_object_from_pack( &self, pack_path: &Path, id: &PackObjectId, ) -> Result<Option<(ObjectType, Vec<u8>)>, HeddleError>
Read id from one specific discovered pack without building the
cross-pack location index. The record identity remains validated by
PackReader; object-domain consumers must validate decoded content.
Sourcepub fn list_ids_from_pack(
&self,
pack_path: &Path,
) -> Result<Vec<PackObjectId>, HeddleError>
pub fn list_ids_from_pack( &self, pack_path: &Path, ) -> Result<Vec<PackObjectId>, HeddleError>
List the identities in one specific pack without building the cross-pack location index.
pub fn get_hashed_object( &self, hash: &ContentHash, ) -> Result<Option<(ObjectType, Vec<u8>)>, HeddleError>
Sourcepub fn get_hashed_object_type(
&self,
hash: &ContentHash,
) -> Result<Option<ObjectType>, HeddleError>
pub fn get_hashed_object_type( &self, hash: &ContentHash, ) -> Result<Option<ObjectType>, HeddleError>
Look up the logical object type without decoding the object payload.
Sourcepub fn get_hashed_object_bytes(
&self,
hash: &ContentHash,
) -> Result<Option<(ObjectType, Bytes)>, HeddleError>
pub fn get_hashed_object_bytes( &self, hash: &ContentHash, ) -> Result<Option<(ObjectType, Bytes)>, HeddleError>
Zero-copy variant of get_hashed_object. Returns
bytes::Bytes views into the underlying pack mmap when
the entry is non-delta and stored uncompressed; falls back
to the standard decompress-into-Vec path otherwise.
pub fn has_object(&self, hash: &ContentHash) -> bool
Sourcepub fn get_hashed_object_size(
&self,
hash: &ContentHash,
) -> Result<Option<u64>, HeddleError>
pub fn get_hashed_object_size( &self, hash: &ContentHash, ) -> Result<Option<u64>, HeddleError>
Look up the uncompressed size of hash across all loaded
packs without decompressing the payload. Returns Ok(None)
when the object isn’t in any loaded pack.
pub fn has_object_id(&self, id: &PackObjectId) -> bool
Sourcepub fn list_all_hashes(&self) -> Result<Vec<ContentHash>, HeddleError>
pub fn list_all_hashes(&self) -> Result<Vec<ContentHash>, HeddleError>
List all object hashes across all packs.
pub fn list_all_ids(&self) -> Result<Vec<PackObjectId>, HeddleError>
Sourcepub fn pack_file_paths(&self) -> Vec<(&Path, &Path)>
pub fn pack_file_paths(&self) -> Vec<(&Path, &Path)>
Return paths of all pack files (for deletion during aggressive repack).