Skip to main content

read_blob

Function read_blob 

Source
pub async fn read_blob(
    remote: &Remote,
    ref_name: &str,
    path: &str,
    cache: &PackIndexCache,
) -> Result<Bytes, PackchainError>
Expand description

Read the contents of path at ref_name’s tip from a packchain remote.

Walks chain.json + path-index.json to resolve path → blob SHA, then consults each segment’s .idx newest-first for the blob’s pack entry. The matching entry’s bytes are fetched via a ranged GET, zlib-decompressed, and (when the entry is a delta) recursively resolved against its base. The entry’s eventual blob payload is returned as an owned Bytes.

cache amortises pack-index parsing across calls within the same process. Long-running consumers (CI agents, build systems) should keep one PackIndexCache for the lifetime of the process so the per-call cost is one or two API calls plus a zlib inflate; one-shot callers can pass &PackIndexCache::default() and discard.

§Errors