Struct combine::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")
        .parse(State::new(&b"8"[..]));
    assert_eq!(result, Err(ParseError {
        position: 0,
        errors: vec![
            Error::Unexpected(b'8'.into()),
            Error::Expected(b'9'.into()),
            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]

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]

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]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

Formats the value using the given formatter.

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

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

This method tests for !=.

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

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

Returns the current position of the stream.

impl<I, X> StreamOnce for State<I, X> where
    I: StreamOnce,
    X: Positioner<I::Item>, 
[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

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

impl<I, X> RangeStream for State<I, X> where
    I: RangeStream,
    X: Clone + RangePositioner<I::Item, I::Range>,
    I::Position: Clone + Ord
[src]

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

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

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

impl<I, X> FullRangeStream for State<I, X> where
    I: FullRangeStream,
    I::Position: Clone + Ord,
    X: Clone + RangePositioner<I::Item, I::Range>, 
[src]

Returns the entire range of self