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>
Cheap check: does the packs directory hold more pack/index
pairs than we have loaded? Reuses discover_pack_paths so
half-installed packs (a .pack whose .idx sibling hasn’t
landed yet) are filtered out — otherwise we’d loop forever
reloading a count we can never match.
Sourcepub fn reload_if_disk_grew(&mut self) -> Result<bool, HeddleError>
pub fn reload_if_disk_grew(&mut self) -> Result<bool, HeddleError>
Reload the pack list only if the packs directory has more pack/index pairs on disk than we know about in memory.
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>
pub fn get_hashed_object( &self, hash: &ContentHash, ) -> Result<Option<(ObjectType, Vec<u8>)>, HeddleError>
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).