pub struct FastCDC { /* private fields */ }Expand description
A content-defined chunker that splits a byte stream at boundaries determined by the content itself.
Create via FastCDC::new or use the Default implementation
(which uses the spec’s default sizes). Then call chunk_reader
or chunk_slice to produce chunks.
Implementations§
Source§impl FastCDC
impl FastCDC
Sourcepub fn new(
min_size: usize,
avg_size: usize,
max_size: usize,
) -> Result<Self, &'static str>
pub fn new( min_size: usize, avg_size: usize, max_size: usize, ) -> Result<Self, &'static str>
Construct a chunker with explicit size parameters.
§Errors
Returns &str if the sizes are inconsistent:
min_size == 0min_size >= avg_sizeavg_size >= max_size
Sourcepub fn chunk_slice<'a>(&self, data: &'a [u8]) -> Vec<&'a [u8]>
pub fn chunk_slice<'a>(&self, data: &'a [u8]) -> Vec<&'a [u8]>
Split data into content-defined chunks.
Returns a Vec of byte slices borrowing from data. The
concatenation of the slices equals data. The last chunk may
be smaller than min_size (if the input is short or the final
chunk happens to be the tail after the last boundary).
Trait Implementations§
Source§impl Chunker for FastCDC
impl Chunker for FastCDC
Source§fn chunk_slice<'a>(&self, data: &'a [u8]) -> Vec<&'a [u8]>
fn chunk_slice<'a>(&self, data: &'a [u8]) -> Vec<&'a [u8]>
Split
data into content-defined chunks. The concatenation
of the returned slices equals data.Source§fn chunk_reader<R: Read>(&self, reader: R) -> Result<Vec<Vec<u8>>>
fn chunk_reader<R: Read>(&self, reader: R) -> Result<Vec<Vec<u8>>>
Split a
Read stream into content-defined chunks, returning
each chunk as an owned Vec<u8>. Constant memory bounded by
the chunker’s max chunk size plus one read buffer. Read moreSource§fn avg_chunk_size(&self) -> usize
fn avg_chunk_size(&self) -> usize
Target average chunk size.
Auto Trait Implementations§
impl Freeze for FastCDC
impl RefUnwindSafe for FastCDC
impl Send for FastCDC
impl Sync for FastCDC
impl Unpin for FastCDC
impl UnsafeUnpin for FastCDC
impl UnwindSafe for FastCDC
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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