Expand description
§use-yaml
Practical YAML utility primitives for lightweight document markers, indentation, and key-value handling.
Warning: versions below
0.3.0are experimental and may change as the crate matures.
§Example Usage
use use_yaml::{extract_yaml_key_values, is_yaml_document_start, quote_yaml_string, yaml_indent};
let values = extract_yaml_key_values("---\nname: RustUse\n enabled: true\n...\n");
assert!(is_yaml_document_start("---"));
assert_eq!(values[0].key, "name");
assert_eq!(values[1].indent, 2);
assert_eq!(yaml_indent(" key: value"), 4);
assert_eq!(quote_yaml_string("it's ready"), "'it''s ready'");§Scope
- document marker detection and stripping
- list-item and indentation helpers
- conservative mapping-style key-value splitting and extraction
§Non-Goals
- a full YAML parser
- anchor or alias resolution
- schema validation
§License
Licensed under either of the following, at your option:
- MIT License
- Apache License, Version 2.0
Structs§
- Yaml
KeyValue - A discovered YAML mapping entry.
Functions§
- extract_
yaml_ key_ values - Extracts simple YAML mapping entries from the input.
- is_
yaml_ document_ end - Returns
truewhen a line is a YAML document end marker. - is_
yaml_ document_ start - Returns
truewhen a line is a YAML document start marker. - is_
yaml_ list_ item - Returns
truewhen a line is a YAML list item. - looks_
like_ yaml - Returns
truewhen the input contains YAML-like markers, list items, or mappings. - quote_
yaml_ string - Quotes a string as a single-quoted YAML scalar.
- split_
yaml_ key_ value - Splits a simple YAML mapping line on the first
:outside quotes. - strip_
yaml_ document_ markers - Strips leading and trailing YAML document markers when they are present.
- yaml_
indent - Counts leading space indentation on a YAML line.