Skip to main content

visit_reader

Function visit_reader 

Source
pub fn visit_reader<E: From<ArtifactError>>(
    reader: &mut impl Read,
    buffer: &mut [u8],
    limit: u64,
    visit: impl FnMut(&[u8]) -> Result<(), E>,
) -> Result<u64, E>
Expand description

Visit bounded stream chunks using nonempty caller-owned scratch space.

Returns the complete byte count, observing at most limit + 1 bytes. Only interrupted reads are retried. An overflowing chunk is not passed to visit; earlier callback effects remain when a later read, limit or callback fails. Chunks borrow buffer only during each call. Its contents after return are unspecified. Callers own framing, retained observations and blocking deadlines. No allocation, digest framing, filesystem or lifecycle policy is supplied.

ยงErrors

Returns original callback errors or converted ArtifactError read/limit errors. Empty scratch is invalid input; impossible read counts are invalid data.