Module chomp::buffer [] [src]

Utilities for parsing streams of data.

Examples

use std::fs::File;

use chomp::buffer;
use chomp::buffer::Stream;
use chomp::prelude::{token, take_while, take_while1};
use chomp::ascii::is_whitespace;

let f = File::open("./README.md").unwrap();

let mut b = buffer::Source::from_read(f, buffer::FixedSizeBuffer::new());

let r = b.parse(parser!{
    take_while(|c| c != b'#');
    token(b'#');
    take_while1(is_whitespace);
    take_while1(|c| c != b'\r' && c != b'\n')
});

assert_eq!(r, Ok(&b"Chomp"[..]));

Reexports

pub use self::data_source::DataSource;
pub use self::data_source::RWDataSource;

Modules

data_source

Implementation of datasources for Source.

Structs

FixedSizeBuffer

A fixed size buffer.

GrowingBuffer

A buffer which will reallocate to fit the requested amount of data.

InputBuf

Input buffer type which contains a flag which tells if we might need to read more data.

SliceStream

Stream implementation for immutable slices.

Source

Manages a buffer and data source pair, enabling efficient parsing from a streaming source.

Enums

StreamError

Error type for parsing using the Stream trait.

Traits

Buffer

Trait all parser buffers implement.

Stream

Trait wrapping the state management in reading from a data source while parsing.