Struct combine::stream::buffered::BufferedStream [−][src]
Stream
which buffers items from an instance of StreamOnce
into a ring buffer.
Instances of StreamOnce
which is not able to implement Resetable
(such as ReadStream
) may
use this as a way to implement Resetable
and become a full Stream
instance.
The drawback is that the buffer only stores a limited number of items which limits how many
tokens that can be reset and replayed. If a BufferedStream
is reset past this limit an error
will be returned when uncons
is next called.
NOTE: If this stream is used in conjunction with an error enhancing stream such as
easy::Stream
(also via the easy_parser
method) it is recommended that the BufferedStream
instance wraps the easy::Stream
instance instead of the other way around.
// DO BufferedStream::new(easy::Stream(..), ..) // DON'T easy::Stream(BufferedStream::new(.., ..)) parser.easy_parse(BufferedStream::new(..));
Implementations
impl<I> BufferedStream<I> where
I: StreamOnce + Positioned,
I::Position: Clone,
I::Item: Clone,
[src]
I: StreamOnce + Positioned,
I::Position: Clone,
I::Item: Clone,
pub fn new(iter: I, lookahead: usize) -> BufferedStream<I>
[src]
Constructs a new BufferedStream
from a StreamOnce
instance with a lookahead
number of elements that can be stored in the buffer.
Trait Implementations
impl<I: Debug> Debug for BufferedStream<I> where
I: StreamOnce + Positioned,
I::Item: Debug,
I::Position: Debug,
[src]
I: StreamOnce + Positioned,
I::Item: Debug,
I::Position: Debug,
impl<I: PartialEq> PartialEq<BufferedStream<I>> for BufferedStream<I> where
I: StreamOnce + Positioned,
I::Item: PartialEq,
I::Position: PartialEq,
[src]
I: StreamOnce + Positioned,
I::Item: PartialEq,
I::Position: PartialEq,
fn eq(&self, other: &BufferedStream<I>) -> bool
[src]
fn ne(&self, other: &BufferedStream<I>) -> bool
[src]
impl<I> Positioned for BufferedStream<I> where
I: StreamOnce + Positioned,
[src]
I: StreamOnce + Positioned,
impl<I> Resetable for BufferedStream<I> where
I: Positioned,
[src]
I: Positioned,
type Checkpoint = usize
fn checkpoint(&self) -> Self::Checkpoint
[src]
fn reset(&mut self, checkpoint: Self::Checkpoint)
[src]
impl<I> StreamOnce for BufferedStream<I> where
I: StreamOnce + Positioned,
I::Item: Clone + PartialEq,
[src]
I: StreamOnce + Positioned,
I::Item: Clone + PartialEq,
type Item = I::Item
The type of items which is yielded from this stream.
type Range = I::Range
The type of a range of items yielded from this stream.
Types which do not a have a way of yielding ranges of items should just use the
Self::Item
for this type. Read more
type Position = I::Position
Type which represents the position in a stream.
Ord
is required to allow parsers to determine which of two positions are further ahead. Read more
type Error = I::Error
fn uncons(&mut self) -> Result<I::Item, StreamErrorFor<Self>>
[src]
fn is_partial(&self) -> bool
[src]
impl<I> StructuralPartialEq for BufferedStream<I> where
I: StreamOnce + Positioned,
[src]
I: StreamOnce + Positioned,
Auto Trait Implementations
impl<I> RefUnwindSafe for BufferedStream<I> where
I: RefUnwindSafe,
<I as StreamOnce>::Item: RefUnwindSafe,
<I as StreamOnce>::Position: RefUnwindSafe,
I: RefUnwindSafe,
<I as StreamOnce>::Item: RefUnwindSafe,
<I as StreamOnce>::Position: RefUnwindSafe,
impl<I> Send for BufferedStream<I> where
I: Send,
<I as StreamOnce>::Item: Send,
<I as StreamOnce>::Position: Send,
I: Send,
<I as StreamOnce>::Item: Send,
<I as StreamOnce>::Position: Send,
impl<I> Sync for BufferedStream<I> where
I: Sync,
<I as StreamOnce>::Item: Sync,
<I as StreamOnce>::Position: Sync,
I: Sync,
<I as StreamOnce>::Item: Sync,
<I as StreamOnce>::Position: Sync,
impl<I> Unpin for BufferedStream<I> where
I: Unpin,
<I as StreamOnce>::Item: Unpin,
<I as StreamOnce>::Position: Unpin,
I: Unpin,
<I as StreamOnce>::Item: Unpin,
<I as StreamOnce>::Position: Unpin,
impl<I> UnwindSafe for BufferedStream<I> where
I: UnwindSafe,
<I as StreamOnce>::Item: UnwindSafe,
<I as StreamOnce>::Position: UnwindSafe,
I: UnwindSafe,
<I as StreamOnce>::Item: UnwindSafe,
<I as StreamOnce>::Position: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> Stream for I where
I: StreamOnce + Positioned + Resetable,
<I as StreamOnce>::Error: ParseError<<I as StreamOnce>::Item, <I as StreamOnce>::Range, <I as StreamOnce>::Position>,
[src]
I: StreamOnce + Positioned + Resetable,
<I as StreamOnce>::Error: ParseError<<I as StreamOnce>::Item, <I as StreamOnce>::Range, <I as StreamOnce>::Position>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,