Skip to main content

Parser

Struct Parser 

Source
pub struct Parser<'a> { /* private fields */ }
Expand description

A BTOR2 parser.

Implementations§

Source§

impl<'a> Parser<'a>

Source

pub fn new(reader: LineReader<'a>, config: Config) -> Result<Self, ParseError>

Creates a parser reading from a LineReader.

Source

pub fn from_buf_reader( buf_reader: BufReader<impl Read + 'a>, config: Config, ) -> Result<Self, ParseError>

Creates a parser reading from a BufReader.

Source

pub fn from_read( read: impl Read + 'a, config: Config, ) -> Result<Self, ParseError>

Creates a parser reading from a Read instance.

If the Read instance is a BufReader, it is better to use from_buf_reader to avoid unnecessary double buffering of the data.

Examples found in repository?
examples/roundtrip.rs (line 17)
13fn main_err() -> Result<(), ParseError> {
14    let stdin = std::io::stdin();
15    let stdout = std::io::stdout();
16
17    let mut parser = Parser::from_read(stdin, Default::default())?;
18    let mut target = DeferredWriter::from_write(stdout);
19
20    while let Some(line) = parser.next_line()? {
21        line.write_into(&mut target);
22    }
23    target.flush()?;
24
25    Ok(())
26}
Source

pub fn from_boxed_dyn_read( read: Box<dyn Read + 'a>, config: Config, ) -> Result<Self, ParseError>

Creates a parser reading from a boxed Read instance.

If the Read instance is a BufReader, it is better to use from_buf_reader to avoid unnecessary double buffering of the data.

Source

pub fn next_line(&mut self) -> Result<Option<Line<'_>>, ParseError>

Parses the next line of the BTOR2 file.

Returns Ok(None) when reaching the end of the file.

Examples found in repository?
examples/roundtrip.rs (line 20)
13fn main_err() -> Result<(), ParseError> {
14    let stdin = std::io::stdin();
15    let stdout = std::io::stdout();
16
17    let mut parser = Parser::from_read(stdin, Default::default())?;
18    let mut target = DeferredWriter::from_write(stdout);
19
20    while let Some(line) = parser.next_line()? {
21        line.write_into(&mut target);
22    }
23    target.flush()?;
24
25    Ok(())
26}

Auto Trait Implementations§

§

impl<'a> Freeze for Parser<'a>

§

impl<'a> !RefUnwindSafe for Parser<'a>

§

impl<'a> !Send for Parser<'a>

§

impl<'a> !Sync for Parser<'a>

§

impl<'a> Unpin for Parser<'a>

§

impl<'a> UnsafeUnpin for Parser<'a>

§

impl<'a> !UnwindSafe for Parser<'a>

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