pub trait Parser<'i, I, C, S, TK>{
type Output;
// Required methods
fn parse(&self, input: &'i I) -> Result<Self::Output>;
fn parse_with_context(
&self,
context: &mut C,
input: &'i I,
) -> Result<Self::Output>;
fn parse_file<'a, F: AsRef<Path>>(
&'a mut self,
file: F,
) -> Result<Self::Output>
where 'a: 'i;
}
Expand description
The trait implemented by all Rustemo parsers.
Required Associated Types§
Required Methods§
Sourcefn parse(&self, input: &'i I) -> Result<Self::Output>
fn parse(&self, input: &'i I) -> Result<Self::Output>
Parse the given input and produce the result. The output type is set by the parser implementers and it is usually defined by the builder if the building is done during the parse process.
Sourcefn parse_with_context(
&self,
context: &mut C,
input: &'i I,
) -> Result<Self::Output>
fn parse_with_context( &self, context: &mut C, input: &'i I, ) -> Result<Self::Output>
Parse with the given context which has information about the current parsing state (e.g. position, location). Used in situation when we need to continue parsing from a specific state, like in parsing the layout from the current location.
Sourcefn parse_file<'a, F: AsRef<Path>>(&'a mut self, file: F) -> Result<Self::Output>where
'a: 'i,
fn parse_file<'a, F: AsRef<Path>>(&'a mut self, file: F) -> Result<Self::Output>where
'a: 'i,
A convenience method for loading the content from the given file and
calling parse
. The parser will own the content being parsed and thus
has to outlive Self::Output
if it borrows from the content loaded from
the file.
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.