Struct combine::stream::read::Stream

source ·
pub struct Stream<R> { /* private fields */ }
Available on crate feature std only.

Implementations§

source§

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

source

pub fn new(read: R) -> Stream<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::read;
use combine::stream::buffered;
use combine::stream::position;
use std::io::Read;

let input: &[u8] = b"123,";
let stream = buffered::Stream::new(position::Stream::new(read::Stream::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 Stream<R>

source§

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

§

type Token = u8

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

type Range = &'static [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::Token for this type.
§

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

type Error = Error

source§

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

Takes a stream and removes its first token, yielding the token 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 Stream<R>
where R: Freeze,

§

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

§

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

§

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

§

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

§

impl<R> UnwindSafe for Stream<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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more