pub async fn collect_nar(
stream: Pin<Box<dyn Stream<Item = Result<Bytes, StoreError>> + Send>>,
limit: Option<usize>,
) -> Result<Vec<u8>, StoreError>Expand description
Drain a NarStream into one buffer.
This is the unbounded path. It exists for callers that genuinely need the
whole NAR (the get_nar convenience verb, test doubles) and for capped tiers
via limit. Every use is a deliberate decision to hold O(nar) bytes.
limit — when Some(max), collection refuses the moment the accumulated
length would exceed max, returning StoreError::TooLarge. It never
accumulates past the cap, so a capped caller’s peak is max + NAR_CHUNK_BYTES
and not one byte more.
§Errors
Propagates any error the stream yields, or StoreError::TooLarge when a
limit is set and exceeded.