combine::stream

Struct ReadStream

Source
pub struct ReadStream<R> { /* private fields */ }

Implementations§

Source§

impl<R> ReadStream<R>
where R: Read,

Source

pub fn new(read: R) -> ReadStream<R>

Creates a StreamOnce instance from a value implementing std::io::Read.

NOTE: This type do not implement Positioned and Clone and must be wrapped with types such as BufferedStreamRef and State to become a Stream which can be parsed

use combine::*;
use combine::parser::byte::*;
use combine::stream::ReadStream;
use combine::stream::buffered::BufferedStream;
use combine::stream::state::State;
use std::io::Read;

let input: &[u8] = b"123,";
let stream = BufferedStream::new(State::new(ReadStream::new(input)), 1);
let result = (many(digit()), byte(b','))
    .parse(stream)
    .map(|t| t.0);
assert_eq!(result, Ok((vec![b'1', b'2', b'3'], b',')));

Trait Implementations§

Source§

impl<R> DefaultPositioned for ReadStream<R>

Source§

impl<R: Read> StreamOnce for ReadStream<R>

Source§

type Item = u8

The type of items which is yielded from this stream.
Source§

type Range = u8

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.
Source§

type Position = usize

Type which represents the position in a stream. Ord is required to allow parsers to determine which of two positions are further ahead.
Source§

type Error = Errors<u8, u8, usize>

Source§

fn uncons(&mut self) -> Result<u8, StreamErrorFor<Self>>

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.
Source§

fn is_partial(&self) -> bool

Returns true if this stream only contains partial input. Read more

Auto Trait Implementations§

§

impl<R> Freeze for ReadStream<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ReadStream<R>
where R: RefUnwindSafe,

§

impl<R> Send for ReadStream<R>
where R: Send,

§

impl<R> Sync for ReadStream<R>
where R: Sync,

§

impl<R> Unpin for ReadStream<R>
where R: Unpin,

§

impl<R> UnwindSafe for ReadStream<R>
where R: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.