[−][src]Struct debcontrol::BufParse
A streaming control file parser that buffers input internally.
This type handles incrementally reading and buffering input from a source implementing the
BufParseInput
trait.
Example
use debcontrol::{BufParse, Streaming}; use std::fs::File; let f = File::open(file_name).unwrap(); let mut buf_parse = BufParse::new(f, 4096); while let Some(result) = buf_parse.try_next().unwrap() { match result { Streaming::Item(paragraph) => { for field in paragraph.fields { println!("{}: {}", field.name, &field.value); } } Streaming::Incomplete => buf_parse.buffer().unwrap() } }
Methods
impl<R: BufParseInput> BufParse<R>
[src]
pub fn new(read: R, chunk_size: usize) -> Self
[src]
Create a new parser.
pub fn buffer(&mut self) -> Result<(), R::Error>
[src]
Read the next chunk of input into the buffer.
pub fn try_next(
&mut self
) -> Result<Option<Streaming<Paragraph>>, BufParseError>
[src]
&mut self
) -> Result<Option<Streaming<Paragraph>>, BufParseError>
Try to parse the next paragraph from the input.
A syntax error encountered during parsing is returned immediately. Otherwise, the nature of
the Ok
result determines what to do next:
- If it's
None
, all input has been parsed. Future calls will continue to returnNone
. - If it's
Streaming::Incomplete
, there's not enough buffered input to make a parsing decision. Callbuffer
to read more input. - If it's
Streaming::Item
, a paragraph was parsed. Calltry_next
again after processing it.
pub fn into_inner(self) -> R
[src]
Consume this BufParse
and return the wrapped input source.
Any input that was already buffered will be lost.
Trait Implementations
Auto Trait Implementations
impl<R> RefUnwindSafe for BufParse<R> where
R: RefUnwindSafe,
R: RefUnwindSafe,
impl<R> Send for BufParse<R> where
R: Send,
R: Send,
impl<R> Sync for BufParse<R> where
R: Sync,
R: Sync,
impl<R> Unpin for BufParse<R> where
R: Unpin,
R: Unpin,
impl<R> UnwindSafe for BufParse<R> where
R: UnwindSafe,
R: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,