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]
fn new(slice: &'i [I]) -> Self
Creates a new stream from an immutable slice.
fn len(&self) -> usize
The number of bytes left in the buffer
fn is_empty(&self) -> bool
Returns true if no more bytes are available
Trait Implementations
impl<'i, I: Debug + 'i> Debug for SliceStream<'i, I>
[src]
impl<'i, I: Eq + 'i> Eq for SliceStream<'i, I>
[src]
impl<'i, I: PartialEq + 'i> PartialEq for SliceStream<'i, I>
[src]
fn eq(&self, __arg_0: &SliceStream<'i, I>) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &SliceStream<'i, I>) -> bool
This method tests for !=
.
impl<'i, I: Hash + 'i> Hash for SliceStream<'i, I>
[src]
fn hash<__HI: Hasher>(&self, __arg_0: &mut __HI)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
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]
type Input = InputBuf<'i, I>
The input item type, usually depending on which DataSource
is used.
fn parse<F, T, E>(
&'a mut self,
f: F
) -> Result<T, StreamError<<Self::Input as Input>::Buffer, E>> where
F: FnOnce(Self::Input) -> ParseResult<Self::Input, T, E>,
T: 'i,
E: 'i,
&'a mut self,
f: F
) -> Result<T, StreamError<<Self::Input as Input>::Buffer, E>> where
F: FnOnce(Self::Input) -> ParseResult<Self::Input, T, E>,
T: 'i,
E: 'i,
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