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

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

Stream which buffers items from an instance of StreamOnce into a ring buffer. Instancs 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.

Be careful when using this code, it's not being tested!
// DO
BufferedStream::new(easy::Stream(..), ..)
// DONT
easy::Stream(BufferedStream::new(.., ..))
parser.easy_parse(BufferedStream::new(..));

Methods

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

[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]

[src]

Formats the value using the given formatter.

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

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl<I> Resetable for BufferedStream<I> where
    I: Positioned
[src]

[src]

[src]

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

[src]

Returns the current position of the stream.

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

The type of items which is yielded from this stream.

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 which represents the position in a stream. Ord is required to allow parsers to determine which of two positions are further ahead. Read more

[src]

Takes a stream and removes its first item, yielding the item and the rest of the elements. Returns Err if no element could be retrieved. Read more

[src]

Returns true if this stream only contains partial input. Read more