Function libyml::yaml_parser_parse
source · pub unsafe fn yaml_parser_parse(
parser: *mut YamlParserT,
event: *mut YamlEventT,
) -> Success
Expand description
Parse the input stream and produce the next parsing event.
This function should be called repeatedly to produce a sequence of events
corresponding to the input stream. The initial event will be of type
YamlStreamStartEvent
, and the final event will be of type YamlStreamEndEvent
.
§Safety
This function is unsafe because:
- It operates on raw pointers.
- It assumes certain memory layouts and alignments.
- It may cause undefined behavior if the input pointers are invalid or if the function is misused.
§Arguments
parser
- A pointer to a properly initializedYamlParserT
struct.event
- A pointer to aYamlEventT
struct that will be filled with the next event.
§Returns
Returns OK
if an event was successfully parsed, or FAIL
if:
- The stream has ended (stream_end_produced is true)
- There’s an existing error in the parser
- The parser is in the end state
§Errors
This function will return FAIL
if any of the above error conditions are met.
The caller should check the parser’s error state for more details on the failure.
§Notes
- The caller is responsible for freeing any buffers associated with the produced
event using the
yaml_event_delete()
function. - Do not alternate calls to
yaml_parser_parse()
with calls toyaml_parser_scan()
oryaml_parser_load()
. Doing so will break the parser.