Trait combine::stream::RangeStreamOnce
source · [−]pub trait RangeStreamOnce: StreamOnce + ResetStream {
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::Token) -> bool;
fn distance(&self, end: &Self::Checkpoint) -> usize;
fn range(&self) -> Self::Range;
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>>
where
F: FnMut(Self::Token) -> bool,
{ ... }
}
Expand description
A RangeStream
is an extension of StreamOnce
which allows for zero copy parsing.
Required Methods
fn 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
.
fn uncons_while<F>(&mut self, f: F) -> Result<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_while<F>(&mut self, f: F) -> Result<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
Takes items from stream, testing each one with predicate
.
returns the range of items which passed predicate
.
fn 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
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
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 PeekOk
as it should uncons at least one token.
Implementations on Foreign Types
sourceimpl<'a, I> RangeStreamOnce for &'a mut I where
I: RangeStreamOnce + ?Sized,
impl<'a, I> RangeStreamOnce for &'a mut I where
I: RangeStreamOnce + ?Sized,
fn uncons_while<F>(&mut self, f: F) -> Result<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_range(
&mut self,
size: usize
) -> Result<Self::Range, StreamErrorFor<Self>>
fn distance(&self, end: &Self::Checkpoint) -> usize
fn range(&self) -> Self::Range
sourceimpl<'a> RangeStreamOnce for &'a str
impl<'a> RangeStreamOnce for &'a str
fn uncons_while<F>(&mut self, f: F) -> Result<&'a str, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_range(&mut self, size: usize) -> Result<&'a str, StreamErrorFor<Self>>
fn distance(&self, end: &Self) -> usize
fn range(&self) -> Self::Range
sourceimpl<'a, T> RangeStreamOnce for &'a [T] where
T: Clone + PartialEq,
impl<'a, T> RangeStreamOnce for &'a [T] where
T: Clone + PartialEq,
fn uncons_range(&mut self, size: usize) -> Result<&'a [T], StreamErrorFor<Self>>
fn uncons_while<F>(&mut self, f: F) -> Result<&'a [T], StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn uncons_while1<F>(
&mut self,
f: F
) -> ParseResult<Self::Range, StreamErrorFor<Self>> where
F: FnMut(Self::Token) -> bool,
fn distance(&self, end: &Self) -> usize
fn range(&self) -> Self::Range
Implementors
impl<'a, T> RangeStreamOnce for SliceStream<'a, T> where
T: PartialEq + 'a,
impl<Input, X, S> RangeStreamOnce for combine::stream::position::Stream<Input, X> where
Input: RangeStreamOnce,
X: RangePositioner<Input::Token, Input::Range>,
S: StreamError<Input::Token, Input::Range>,
Input::Error: ParseError<Input::Token, Input::Range, X::Position, StreamError = S>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position, StreamError = S>,
Input::Position: Clone + Ord,
impl<S> RangeStreamOnce for combine::stream::easy::Stream<S> where
S: RangeStream,
S::Token: PartialEq,
S::Range: PartialEq,
Available on crate feature
std
only.