pub struct StreamChunker<R: Read> { /* private fields */ }Expand description
An iterator over content-defined ChunkDigests read from an io::Read.
Internally buffers data in a fixed-size heap buffer so the caller’s memory
usage is bounded regardless of file size. The I/O buffer io_buf holds
the most recently read batch; io_pos tracks where processing should resume
within that batch, allowing the chunker to return mid-buffer and resume on
the next call without discarding unprocessed bytes.
Implementations§
Source§impl<R: Read> StreamChunker<R>
impl<R: Read> StreamChunker<R>
Sourcepub fn new(reader: R, config: StreamChunkerConfig) -> Self
pub fn new(reader: R, config: StreamChunkerConfig) -> Self
Create a new StreamChunker wrapping reader.
Sourcepub fn collect_all(self) -> Result<Vec<ChunkDigest>>
pub fn collect_all(self) -> Result<Vec<ChunkDigest>>
Collect all chunk digests eagerly, consuming self.
§Errors
Propagates any io::Error from the underlying reader.
Sourcepub fn next_chunk(&mut self) -> Result<Option<ChunkDigest>>
pub fn next_chunk(&mut self) -> Result<Option<ChunkDigest>>
Advance to the next chunk.
Returns Ok(None) when the stream is exhausted.
§Errors
Returns an io::Error on read failure.
Auto Trait Implementations§
impl<R> Freeze for StreamChunker<R>where
R: Freeze,
impl<R> RefUnwindSafe for StreamChunker<R>where
R: RefUnwindSafe,
impl<R> Send for StreamChunker<R>where
R: Send,
impl<R> Sync for StreamChunker<R>where
R: Sync,
impl<R> Unpin for StreamChunker<R>where
R: Unpin,
impl<R> UnsafeUnpin for StreamChunker<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for StreamChunker<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more