Trait hash_roll::Splitter
[−]
[src]
pub trait Splitter { fn next_iter<T: Iterator<Item = u8>>(&self, iter: T) -> Option<Vec<u8>>; fn find_chunk_edge(&self, data: &[u8]) -> usize { ... } fn split<'b>(&self, data: &'b [u8]) -> (&'b [u8], &'b [u8]) { ... } fn into_slices<'a>(self, data: &'a [u8]) -> SplitterSlices<'a, Self>
where
Self: Sized, { ... } fn as_slices<'a>(&'a self, data: &'a [u8]) -> SplitterSlices<'a, &Self>
where
Self: Sized, { ... } fn into_vecs<'a, T: Iterator<Item = u8>>(
self,
data: T
) -> SplitterVecs<T, Self>
where
Self: Sized, { ... } fn as_vecs<'a, T: Iterator<Item = u8>>(
&'a self,
data: T
) -> SplitterVecs<T, &Self>
where
Self: Sized, { ... } }
An object with transforms a stream of bytes into chunks, potentially by examining the bytes
Required Methods
fn next_iter<T: Iterator<Item = u8>>(&self, iter: T) -> Option<Vec<u8>>
Return chunks from a given iterator, split according to the splitter used.
See the iterator generator functions into_vecs
and
as_vecs
which provide a more ergonomic interface to this.
FIXME: discards internal state when the edge is not found at the end of the input iterator, meaning a user of this API would have to re-process the entire thing.
Provided Methods
fn find_chunk_edge(&self, data: &[u8]) -> usize
Find the location (if any) to split data
based on this splitter.
FIXME: discards internal state when the edge is not found, meaning a user of this API would have to re-process the entire thing.
Implimentor's Note
The provided implimentation uses Splitter::split
.
You must impliment either this function or split
.
fn split<'b>(&self, data: &'b [u8]) -> (&'b [u8], &'b [u8])
Split data into 2 pieces using a given splitter.
It is expected that in most cases the second element of the return value will be split further by calling this function again.
FIXME: discards internal state when the edge is not found, meaning a user of this API would have to re-process the entire thing.
Implimentor's Note
The provided implimentation uses find_chunk_edge
.
You must impliment either this function or find_chunk_edge
.
fn into_slices<'a>(self, data: &'a [u8]) -> SplitterSlices<'a, Self> where
Self: Sized,
Self: Sized,
Create an iterator over slices from a slice and a splitter. The splitter is consumed.
fn as_slices<'a>(&'a self, data: &'a [u8]) -> SplitterSlices<'a, &Self> where
Self: Sized,
Self: Sized,
fn into_vecs<'a, T: Iterator<Item = u8>>(self, data: T) -> SplitterVecs<T, Self> where
Self: Sized,
Self: Sized,
Create an iterator of Vec<u8>
from an input Iterator of bytes.
The splitter is consumed.
fn as_vecs<'a, T: Iterator<Item = u8>>(
&'a self,
data: T
) -> SplitterVecs<T, &Self> where
Self: Sized,
&'a self,
data: T
) -> SplitterVecs<T, &Self> where
Self: Sized,