pub struct Parser<'input> {
pub pin: Owned<ParserPinned<'input>>,
}Expand description
Represents a YAML parser.
The Parser struct is responsible for parsing YAML input and generating a sequence
of YAML events. It wraps the underlying libyml parser and provides a safe and
convenient interface for parsing YAML documents.
The 'input lifetime parameter indicates the lifetime of the input data being parsed.
It ensures that the Parser does not outlive the input data.
Fields§
§pin: Owned<ParserPinned<'input>>The pinned parser state.
The Owned<ParserPinned<'input>> type represents an owned instance of the
ParserPinned struct. The Owned type is used to provide pinning and
allows the Parser to be safely moved around.
The ParserPinned struct contains the underlying libyml parser state
and the input data being parsed.
Pinning is used to ensure that the Parser remains at a fixed memory
location, which is required for safe interaction with the libyml library.
Implementations§
Source§impl<'input> Parser<'input>
impl<'input> Parser<'input>
Sourcepub fn new(input: Cow<'input, [u8]>) -> Parser<'input>
pub fn new(input: Cow<'input, [u8]>) -> Parser<'input>
Creates a new Parser instance with the given input data.
The input parameter is of type Cow<'input, [u8]>, which allows the parser
to accept both borrowed slices and owned vectors of bytes as input.
§Panics
This function panics if there is an error initializing the underlying libyml parser.
Sourcepub fn parse_next_event(&mut self) -> Result<(Event<'input>, Mark)>
pub fn parse_next_event(&mut self) -> Result<(Event<'input>, Mark)>
Parses the next YAML event from the input.
Returns a Result containing the parsed Event and its corresponding Mark on success,
or an Error if parsing fails.