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

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

input: I

The input stream used when items are requested

positioner: X

The positioner used to update the current position

Methods

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

pub fn with_positioner(input: I, positioner: X) -> State<I, X>[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]

pub fn new(input: I) -> State<I, I::Positioner>[src]

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

Trait Implementations

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]

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]

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 = X::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, X, S> ResetStream for State<I, X> where
    I: ResetStream,
    X: Clone + 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]

type Checkpoint = State<I::Checkpoint, X>

impl<I, X, S> RangeStreamOnce for State<I, X> where
    I: RangeStreamOnce,
    I: ResetStream,
    X: Clone + 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]

impl<I, X, E> FullRangeStream for State<I, X> where
    I: FullRangeStream + ResetStream,
    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: Clone + RangePositioner<I::Item, I::Range>, 
[src]

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

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

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

Auto Trait Implementations

impl<I, X> Send for State<I, X> where
    I: Send,
    X: Send

impl<I, X> Sync for State<I, X> where
    I: Sync,
    X: 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<I> RangeStream for I where
    I: RangeStreamOnce + Stream
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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]