[][src]Struct combine::stream::buffered::Stream

pub struct Stream<I> where
    I: StreamOnce + Positioned
{ /* fields omitted */ }

Stream which buffers items from an instance of StreamOnce into a ring buffer. Instances of StreamOnce which is not able to implement ResetStream (such as ReadStream) may use this as a way to implement ResetStream 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 buffered::Stream 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 buffered::Stream instance wraps the easy::Stream instance instead of the other way around.

This example is not tested
// DO
buffered::Stream::new(easy::Stream(..), ..)
// DON'T
easy::Stream(buffered::Stream::new(.., ..))
parser.easy_parse(buffered::Stream::new(..));

Methods

impl<I> Stream<I> where
    I: StreamOnce + Positioned,
    I::Position: Clone,
    I::Item: Clone
[src]

pub fn new(iter: I, lookahead: usize) -> Stream<I>[src]

Constructs a new Stream from a StreamOnce instance with a lookahead number of elements that can be stored in the buffer.

Trait Implementations

impl<I> Positioned for Stream<I> where
    I: StreamOnce + Positioned
[src]

impl<I> StreamOnce for Stream<I> where
    I: StreamOnce + Positioned
[src]

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

impl<I> ResetStream for Stream<I> where
    I: Positioned
[src]

type Checkpoint = usize

impl<I: PartialEq> PartialEq<Stream<I>> for Stream<I> where
    I: StreamOnce + Positioned,
    I::Item: PartialEq,
    I::Position: PartialEq
[src]

impl<I: Debug> Debug for Stream<I> where
    I: StreamOnce + Positioned,
    I::Item: Debug,
    I::Position: Debug
[src]

Auto Trait Implementations

impl<I> Send for Stream<I> where
    I: Send,
    <I as StreamOnce>::Item: Send,
    <I as StreamOnce>::Position: Send

impl<I> Sync for Stream<I> where
    I: Sync,
    <I as StreamOnce>::Item: Sync,
    <I as StreamOnce>::Position: Sync

Blanket Implementations

impl<I> Stream for I where
    I: StreamOnce + Positioned + ResetStream,
    <I as StreamOnce>::Error: ParseError<<I as StreamOnce>::Item, <I as StreamOnce>::Range, <I as StreamOnce>::Position>, 
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]