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
PackchainError::WrongEnginewhen the remote’s engine is notStorageEngine::Packchain.PackchainError::ChainAbsentwhen the branch is unknown to the bucket.PackchainError::PathIndexAbsentwhenchain.jsonexists butpath-index.jsondoes not (a partially crashed first push).PackchainError::TransientChainPathIndexMismatchwhen both exist butpath_index.tip != chain.tip— a brief window during a concurrent push or compact wherechain.jsonhas been overwritten ahead ofpath-index.json. Retry-shaped: a subsequent read converges once the writer finishes.PackchainError::MalformedPathfor..segments, leading/, empty path, or empty segments (consecutive slashes).PackchainError::PathNotFoundwhen the path does not exist in the resolved tree.PackchainError::PathNotABlobwhen the path resolves to a directory rather than a file.PackchainError::BlobNotInChainwhen the path-index named a blob SHA absent from every pack referenced bychain.json.PackchainError::DeltaTooDeep/PackchainError::MalformedDelta/PackchainError::MalformedPackEntry/PackchainError::Decompressfor pack-corruption shapes.PackchainError::PackMissing,PackchainError::Store, orPackchainError::Iofor transport / I/O failures.PackchainError::ConcurrentGcRetriesExhaustedwhen a vigorous concurrentmanage gc sweepkept deleting packs the reader had just discovered, exhausting the internal retry schedule. Callers should re-invokeread_blobafter the compaction settles.