Expand description
YAML 1.2 parser implementation in pure Rust.
granit-parser is a low-level event parser. It reads YAML input and yields a stream of
Event values paired with their source Span.
Add it to your project:
cargo add granit-parser§Usage
use granit_parser::{Event, Parser};
let yaml = "items:\n - milk\n - bread\n";
for next in Parser::new_from_str(yaml) {
let (event, _span) = next?;
if let Event::Scalar(value, ..) = event {
println!("{value}");
}
}§Features
Note: This crate’s MSRV is 1.81.0.
§debug_prints
Enables the debug module and usage of debug prints in the scanner and the parser. Do not
enable if you are consuming the crate rather than working on it as this can significantly
decrease performance. Output remains opt-in behind a local compile-time toggle in
src/debug.rs.
This feature does not raise the MSRV further.
This feature is not no_std compatible.
Re-exports§
pub use crate::input::BorrowedInput;pub use crate::input::BufferedInput;pub use crate::input::Input;
Modules§
- input
- Utilities to create a source of input to the parser.
- parser_
stack - A stack-based parser implementation.
Structs§
- Marker
- A location in a yaml document.
- Parser
- A YAML parser.
- Scan
Error - An error that occurred while scanning.
- Scanner
- The YAML scanner.
- Span
- A range of locations in a Yaml document.
- StrInput
- A parser input that uses a
&stras source. - Tag
- A YAML tag.
- Token
- A scanner token.
Enums§
- Event
- An event generated by the YAML parser.
- Scalar
Style - The style as which the scalar was written in the YAML document.
- Token
Type - The contents of a scanner token.
- TryLoad
Error - Error returned by
Parser::try_loadandParserTrait::try_load.
Traits§
- Event
Receiver - Trait to be implemented in order to use the low-level parsing API.
- Parser
Trait - Trait extracted from
Parserto support mocking and alternative implementations. - Spanned
Event Receiver - Trait to be implemented for using the low-level parsing API.
- TryEvent
Receiver - Trait to be implemented for fallible event handling without source spans.
- TrySpanned
Event Receiver - Trait to be implemented for fallible event handling with source spans.