pub struct Parser<'a> { /* private fields */ }Expand description
A BTOR2 parser.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new(reader: LineReader<'a>, config: Config) -> Result<Self, ParseError>
pub fn new(reader: LineReader<'a>, config: Config) -> Result<Self, ParseError>
Creates a parser reading from a LineReader.
Sourcepub fn from_buf_reader(
buf_reader: BufReader<impl Read + 'a>,
config: Config,
) -> Result<Self, ParseError>
pub fn from_buf_reader( buf_reader: BufReader<impl Read + 'a>, config: Config, ) -> Result<Self, ParseError>
Creates a parser reading from a BufReader.
Sourcepub fn from_read(
read: impl Read + 'a,
config: Config,
) -> Result<Self, ParseError>
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}Sourcepub fn from_boxed_dyn_read(
read: Box<dyn Read + 'a>,
config: Config,
) -> Result<Self, ParseError>
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.
Sourcepub fn next_line(&mut self) -> Result<Option<Line<'_>>, ParseError>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more