Struct chomp::buffer::SliceStream [] [src]

pub struct SliceStream<'i, I: 'i> { /* fields omitted */ }

Stream implementation for immutable slices.

use chomp::parsers::{token, take};
use chomp::buffer::{SliceStream, Stream};

let r = SliceStream::new(b"foo").parse(parser!{
    token(b'f');
    take(2)
});

assert_eq!(r, Ok(b"oo" as &[u8]));
use chomp::prelude::{token, many, take};
use chomp::buffer::{SliceStream, Stream};

let r = SliceStream::new(b"foofoo").parse(parser!{many(parser!{
    token(b'f');
    take(2)
})});

assert_eq!(r, Ok(vec![b"oo" as &[u8], b"oo" as &[u8]]));

Methods

impl<'i, I: 'i> SliceStream<'i, I>
[src]

Creates a new stream from an immutable slice.

The number of bytes left in the buffer

Returns true if no more bytes are available

Trait Implementations

impl<'i, I: Debug + 'i> Debug for SliceStream<'i, I>
[src]

Formats the value using the given formatter.

impl<'i, I: Eq + 'i> Eq for SliceStream<'i, I>
[src]

impl<'i, I: PartialEq + 'i> PartialEq for SliceStream<'i, I>
[src]

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

This method tests for !=.

impl<'i, I: Hash + 'i> Hash for SliceStream<'i, I>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<'a, 'i, I: 'i + Copy + PartialEq> Stream<'a, 'i> for SliceStream<'i, I>
[src]

The input item type, usually depending on which DataSource is used.

Attempts to run the supplied parser F once on the currently populated data in this stream, providing a borrow of the inner data storage. Read more