Struct combine::stream::state::State [] [src]

pub struct State<I, X> {
    pub input: I,
    pub positioner: X,
}

The State<I> struct maintains the current position in the stream I using the Positioner trait to track the position.

    let result = token(b'9')
        .message("Not a nine")
        .easy_parse(State::new(&b"8"[..]));
    assert_eq!(result, Err(easy::Errors {
        position: 0,
        errors: vec![
            easy::Error::Unexpected(b'8'.into()),
            easy::Error::Expected(b'9'.into()),
            easy::Error::Message("Not a nine".into())
        ]
    }));

Fields

The input stream used when items are requested

The positioner used to update the current position

Methods

impl<I, X> State<I, X> where
    I: StreamOnce,
    X: Positioner<I::Item>, 
[src]

[src]

Creates a new State<I, X> from an input stream and a positioner.

impl<I> State<I, I::Positioner> where
    I: StreamOnce + DefaultPositioned,
    I::Positioner: Positioner<I::Item>, 
[src]

[src]

Creates a new State<I, X> from an input stream and its default positioner.

Trait Implementations

impl<I: Clone, X: Clone> Clone for State<I, X>
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl<I: Debug, X: Debug> Debug for State<I, X>
[src]

[src]

Formats the value using the given formatter.

impl<I: PartialEq, X: PartialEq> PartialEq for State<I, X>
[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, X, E> Positioned for State<I, X> where
    I: StreamOnce,
    X: Positioner<I::Item>,
    E: StreamError<I::Item, I::Range>,
    I::Error: ParseError<I::Item, I::Range, X::Position, StreamError = E>,
    I::Error: ParseError<I::Item, I::Range, I::Position, StreamError = E>, 
[src]

[src]

Returns the current position of the stream.

impl<I, X, S> StreamOnce for State<I, X> where
    I: StreamOnce,
    X: Positioner<I::Item>,
    S: StreamError<I::Item, I::Range>,
    I::Error: ParseError<I::Item, I::Range, X::Position, StreamError = S>,
    I::Error: ParseError<I::Item, I::Range, I::Position, StreamError = S>, 
[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

impl<I, X, S> RangeStreamOnce for State<I, X> where
    I: RangeStreamOnce,
    X: Resetable + RangePositioner<I::Item, I::Range>,
    S: StreamError<I::Item, I::Range>,
    I::Error: ParseError<I::Item, I::Range, X::Position, StreamError = S>,
    I::Error: ParseError<I::Item, I::Range, I::Position, StreamError = S>,
    I::Position: Clone + Ord
[src]

[src]

Takes size elements from the stream. Fails if the length of the stream is less than size. Read more

[src]

Takes items from stream, testing each one with predicate. returns the range of items which passed predicate. Read more

[src]

Returns the distance between self and end. The returned usize must be so that Read more

impl<I, X> Resetable for State<I, X> where
    I: Resetable,
    X: Resetable
[src]

[src]

[src]

impl<I, X, E> FullRangeStream for State<I, X> where
    I: FullRangeStream + Resetable,
    I::Position: Clone + Ord,
    E: StreamError<I::Item, I::Range>,
    I::Error: ParseError<I::Item, I::Range, X::Position, StreamError = E>,
    I::Error: ParseError<I::Item, I::Range, I::Position, StreamError = E>,
    X: Resetable + RangePositioner<I::Item, I::Range>, 
[src]

[src]

Returns the entire range of self