pub trait LogParser: LogParserHelper {
// Required methods
fn process_line(&mut self, line: &str, line_no: usize) -> FResult<bool>;
fn end_of_file(&mut self);
// Provided methods
fn is_line_start(&mut self, _first_byte: u8) -> bool { ... }
fn from<'r, R: BufRead + 'r>(reader: R) -> StreamParser<'r, Self> { ... }
fn from_async<'r, R: AsyncBufRead + Unpin + 'r>(
reader: R,
) -> AsyncParser<'r, Self> { ... }
fn from_str(s: &str) -> StreamParser<'_, Self> { ... }
fn from_str_all(s: &str) -> Result<Self, FatalError> { ... }
fn from_string(s: String) -> StreamParser<'static, Self> { ... }
fn from_string_all(s: String) -> Result<Self, FatalError> { ... }
fn from_file<P: AsRef<Path>>(
p: P,
) -> Result<(Metadata, StreamParser<'static, Self>)> { ... }
fn from_file_all<P: AsRef<Path>>(p: P) -> Result<Self, FatalError> { ... }
}
Expand description
Trait for a generic SMT solver trace parser. Intended to support different solvers or log formats.
Required Methods§
Sourcefn process_line(&mut self, line: &str, line_no: usize) -> FResult<bool>
fn process_line(&mut self, line: &str, line_no: usize) -> FResult<bool>
Process a single line of the log file. Return true
if parsing should
continue, or false
if parsing should stop.
fn end_of_file(&mut self)
Provided Methods§
Sourcefn is_line_start(&mut self, _first_byte: u8) -> bool
fn is_line_start(&mut self, _first_byte: u8) -> bool
Can be used to allow for parsing entries across multiple lines.
Sourcefn from<'r, R: BufRead + 'r>(reader: R) -> StreamParser<'r, Self>
fn from<'r, R: BufRead + 'r>(reader: R) -> StreamParser<'r, Self>
Creates a new parser. Only use this if you cannot use the following convenience methods:
- [
new_file
] for creating a streaming parser from a file path - [
new_str
] or [new_string
] for creating a parser from a strings
Sourcefn from_async<'r, R: AsyncBufRead + Unpin + 'r>(
reader: R,
) -> AsyncParser<'r, Self>
fn from_async<'r, R: AsyncBufRead + Unpin + 'r>( reader: R, ) -> AsyncParser<'r, Self>
Creates a new async parser from an async buffered reader. The parser will read rom the reader line-by-line.
Sourcefn from_str(s: &str) -> StreamParser<'_, Self>
fn from_str(s: &str) -> StreamParser<'_, Self>
Creates a new parser from the contents of a log file. The string
argument must live as long as parsing is ongoing. Release this
constraint by using take_parser
to end
parsing. If you want the parser to take ownership of the string instead
(i.e. you are running into lifetime issues), use
from_string
instead.
Sourcefn from_str_all(s: &str) -> Result<Self, FatalError>
fn from_str_all(s: &str) -> Result<Self, FatalError>
See from_str
and process_all
.
Sourcefn from_string(s: String) -> StreamParser<'static, Self>
fn from_string(s: String) -> StreamParser<'static, Self>
Creates a new parser from the contents of a log file. The parser takes ownership over the string.
Sourcefn from_string_all(s: String) -> Result<Self, FatalError>
fn from_string_all(s: String) -> Result<Self, FatalError>
See from_string
and process_all
.
Sourcefn from_file<P: AsRef<Path>>(
p: P,
) -> Result<(Metadata, StreamParser<'static, Self>)>
fn from_file<P: AsRef<Path>>( p: P, ) -> Result<(Metadata, StreamParser<'static, Self>)>
Creates a new streaming parser from a file. Additionally returns the file metadata so that the progress can be calculated from the file size.
This method is an alternative to
from_string(fs::read_to_string(self)?)
. This approach to parsing is
~5% slower, but should use only ~50% as much memory due to not having
the entire loaded String in memory.
Sourcefn from_file_all<P: AsRef<Path>>(p: P) -> Result<Self, FatalError>
fn from_file_all<P: AsRef<Path>>(p: P) -> Result<Self, FatalError>
See from_file
and process_all
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.