pub struct Chunker { /* private fields */ }Expand description
Chunk Generator given an input stream. Do not use directly.
Use chunk_target_default.
Implementations§
Source§impl Chunker
impl Chunker
pub fn new(target_chunk_size: usize) -> Self
Sourcepub fn next_boundary(&mut self, data: &[u8]) -> Option<usize>
pub fn next_boundary(&mut self, data: &[u8]) -> Option<usize>
Looks for the next chunk boundary in the data. Assumes that whatever is in the current state has been prepended to the current data. If a boundary cannot be found based on the current amount of data, then None is returned.
Sourcepub fn next(&mut self, data: &[u8], is_final: bool) -> (Option<Chunk>, usize)
pub fn next(&mut self, data: &[u8], is_final: bool) -> (Option<Chunk>, usize)
Process more data; this is a continuation of any data from before when calls were
Returns the next chunk, if available, and the amount of data that was digested.
If is_final is true, then it is assumed that no more data after this block will come, and any data currently present and at the end will be put into a final chunk.
Sourcepub fn next_block(&mut self, data: &[u8], is_final: bool) -> Vec<Chunk>
pub fn next_block(&mut self, data: &[u8], is_final: bool) -> Vec<Chunk>
Keeps chunking until no more chunks can be reliably produced, returning a vector of the resulting chunks.
Sourcepub fn next_block_bytes(&mut self, data: &Bytes, is_final: bool) -> Vec<Chunk>
pub fn next_block_bytes(&mut self, data: &Bytes, is_final: bool) -> Vec<Chunk>
Keeps chunking until no more chunks can be reliably produced, returning a vector of the resulting chunks.
The data is inserted here as a Bytes object, which means that no copying of the data is performed except at the boundaries. The resulting chunks then end up each holding a reference to the original data object, which will not be deallocated until all the original bytes are gone.
pub fn finish(&mut self) -> Option<Chunk>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Chunker
impl RefUnwindSafe for Chunker
impl Send for Chunker
impl Sync for Chunker
impl Unpin for Chunker
impl UnsafeUnpin for Chunker
impl UnwindSafe for Chunker
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
Source§impl<T> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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