Skip to main content

Crate use_yaml

Crate use_yaml 

Source
Expand description

§use-yaml

Practical YAML utility primitives for lightweight document markers, indentation, and key-value handling.

Warning: versions below 0.3.0 are 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§

YamlKeyValue
A discovered YAML mapping entry.

Functions§

extract_yaml_key_values
Extracts simple YAML mapping entries from the input.
is_yaml_document_end
Returns true when a line is a YAML document end marker.
is_yaml_document_start
Returns true when a line is a YAML document start marker.
is_yaml_list_item
Returns true when a line is a YAML list item.
looks_like_yaml
Returns true when 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.