pub trait RangeStreamOnce: StreamOnce + Resetable {
// Required methods
fn uncons_range(
&mut self,
size: usize,
) -> Result<Self::Range, StreamErrorFor<Self>>;
fn uncons_while<F>(
&mut self,
f: F,
) -> Result<Self::Range, StreamErrorFor<Self>>
where F: FnMut(Self::Item) -> bool;
fn distance(&self, end: &Self::Checkpoint) -> usize;
// Provided method
fn uncons_while1<F>(
&mut self,
f: F,
) -> FastResult<Self::Range, StreamErrorFor<Self>>
where F: FnMut(Self::Item) -> bool { ... }
}
Expand description
A RangeStream
is an extension of StreamOnce
which allows for zero copy parsing.
Required Methods§
Sourcefn uncons_range(
&mut self,
size: usize,
) -> Result<Self::Range, StreamErrorFor<Self>>
fn uncons_range( &mut self, size: usize, ) -> Result<Self::Range, StreamErrorFor<Self>>
Takes size
elements from the stream.
Fails if the length of the stream is less than size
.
Sourcefn uncons_while<F>(&mut self, f: F) -> Result<Self::Range, StreamErrorFor<Self>>
fn uncons_while<F>(&mut self, f: F) -> Result<Self::Range, StreamErrorFor<Self>>
Takes items from stream, testing each one with predicate
.
returns the range of items which passed predicate
.
Sourcefn distance(&self, end: &Self::Checkpoint) -> usize
fn distance(&self, end: &Self::Checkpoint) -> usize
Returns the distance between self
and end
. The returned usize
must be so that
ⓘ
let start = stream.checkpoint();
stream.uncons_range(distance);
stream.distance(&start) == distance
Provided Methods§
Sourcefn uncons_while1<F>(
&mut self,
f: F,
) -> FastResult<Self::Range, StreamErrorFor<Self>>
fn uncons_while1<F>( &mut self, f: F, ) -> FastResult<Self::Range, StreamErrorFor<Self>>
Takes items from stream, testing each one with predicate
returns a range of at least one items which passed predicate
.
§Note
This may not return EmptyOk
as it should uncons at least one item.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.