pub struct Parser<'a> { /* private fields */ }Expand description
Parser.
§Iteration
Box<Parser> implements IntoIterator<Item = Result<Event, ParserError>>,
and thus can be used in for loops. The iterator is fused, and produces
None forever after the end of stream or after a first encountered error.
Implementations§
Source§impl<'a> Parser<'a>
impl<'a> Parser<'a>
Sourcepub fn new<R: Read + 'a>(reader: R) -> Result<Box<Self>, ParserError>
pub fn new<R: Read + 'a>(reader: R) -> Result<Box<Self>, ParserError>
Create a parser with default configuration.
If a custom configuration is needed, use ParserBuilder to build a
Parser instance.
Examples found in repository?
examples/canonicalize.rs (line 7)
5fn main() -> Result<(), Box<dyn error::Error>> {
6 // Parser with default configuration.
7 let parser = libyaml::Parser::new(io::stdin())?;
8
9 // Emitter with custom configuration: enable canonical output.
10 let mut emitter = libyaml::EmitterBuilder::new(io::stdout())?
11 .canonical(true)
12 .finish();
13
14 // Parser implements IntoIterator and thus can be used in a for loop.
15 for event in parser {
16 emitter.emit(event?)?;
17 }
18
19 Ok(())
20}Sourcepub fn parse(&mut self) -> Result<Event, ParserError>
pub fn parse(&mut self) -> Result<Event, ParserError>
Parse an event.
Sourcepub fn as_raw_ptr(&mut self) -> *mut yaml_parser_t
pub fn as_raw_ptr(&mut self) -> *mut yaml_parser_t
Return raw pointer to the underlying yaml_parser_t.
Trait Implementations§
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> !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