Expand description
YAML 1.2.2 parsing, source-preserving editing, typed overlays, and optional Serde conversion.
YamlDoc keeps the original source as its source of truth. Unedited YAML is
returned byte-for-byte, while editor operations queue localized changes and
YamlPatch applies multi-operation YAML or JSON patches transactionally.
use yaml_rt::{YamlDoc, YamlError};
let mut doc = YamlDoc::parse("port: 8080 # selected port\n")?;
doc.set_scalar(&["port"], "9090")?;
assert_eq!(doc.to_string(), "port: 9090 # selected port\n");The default derive feature re-exports YamlRt for named mapping
structs, transparent newtypes, and locally tagged enums. The optional
serde feature re-exports serialization and deserialization APIs for
conversions where presentation preservation is not required, including a
generic Value model.
Structs§
- Children
- Iterator over a node’s children in source order.
- Deserializer
- A Serde deserializer over one YAML stream.
- Diagnostic
- Structured user-facing diagnostic.
- Edit
- Pending source edit used by the patch-based emitter.
- Error
- Error produced while parsing, deserializing, serializing, or writing YAML.
- Fragment
Error - Failure to parse, validate, or render a YAML fragment.
- Json
Pointer - A parsed plain RFC 6901 JSON Pointer.
- LineCol
- One-based line and column location.
- Location
- Location of a deserialization error in the YAML input.
- Mapping
- An insertion-ordered YAML mapping whose keys and values are both
Value. - Node
- Lossless syntax node produced by the CST parser.
- NodeId
- Identifier for a node stored inside a
crate::YamlDoc. - Number
- A YAML integer or floating-point number.
- Pointer
Error - Structured JSON Pointer parse or resolution error.
- Reference
Token - One decoded RFC 6901 reference token.
- Reserved
Directive - Parsed reserved directive metadata.
- Scalar
Resolve Error - Failure to resolve a scalar according to the YAML core schema.
- Semantic
Value Error - Failure while projecting YAML nodes into the JSON-compatible data model.
- Serializer
- A YAML serializer writing one or more documents to an
io::Writesink. - Source
- Original YAML input plus line-start metadata.
- Span
- A byte span inside a
Source. - TagDirective
- Parsed
%TAGdirective metadata. - Token
- Lexical token preserving its exact source span.
- Yaml
Directive - Parsed
%YAMLdirective metadata. - YamlDoc
- A source-preserving YAML document.
- Yaml
Edit Error - Failure while applying a pointer-addressed YAML edit.
- Yaml
Error - Error type for YAML parsing, semantic lookup, typed overlays, and emission.
- Yaml
Event - Semantic YAML event produced by the parser.
- Yaml
Events - On-demand iterator over semantic YAML events.
- Yaml
Fragment - A parsed YAML value document containing exactly one root node.
- Yaml
Number - An exact, finite YAML number normalized for semantic comparison.
- Yaml
Patch - A parsed sequence of RFC 6902-style operations over YAML values.
- Yaml
Patch Error - Failure while parsing or applying a YAML patch.
Enums§
- Collection
Style - YAML collection spelling.
- Diagnostic
Kind - Diagnostic phase.
- Mapping
Entry Style - Formatting controls for inserting a block mapping entry.
- Node
Kind - Node kinds emitted by the CST parser.
- NonFinite
Float - A non-finite YAML float, which is outside the JSON-compatible data model.
- Pointer
Error Kind - Classification of a JSON Pointer parse or resolution failure.
- Resolved
Scalar - YAML 1.2 core-schema interpretation of a scalar.
- Semantic
Kind - Semantic interpretation attached to a lossless CST node.
- Token
Kind - Token kinds emitted by the lossless lexer.
- Value
- A loosely typed YAML value.
- Yaml
Event Kind - Semantic YAML event kinds.
- Yaml
Patch Error Kind - Classification of a YAML patch failure.
- Yaml
Patch Operation - One YAML patch operation.
- Yaml
Scalar Style - YAML scalar spelling.
Constants§
- TARGET_
YAML_ VERSION - YAML version targeted by this workspace.
Traits§
- From
Yaml Doc - Converts a YAML document into a typed overlay.
- Index
- A sealed type that can index a YAML
ValueorMapping. - ToYaml
Doc - Applies a typed overlay back to a YAML document as minimal patches.
- ToYaml
Fragment - Formats a typed value as a YAML fragment for parent-aware insertions.
- Yaml
Flatten - Reads and writes a field flattened into its containing YAML mapping.
- Yaml
Value - Reads and writes individual YAML node values.
Functions§
- events_
to_ test_ string - Renders YAML events in the YAML Test Suite
test.eventformat. - from_
reader - Deserializes exactly one owned YAML document from a reader.
- from_
slice - Deserializes exactly one YAML document from a byte slice.
- from_
str - Deserializes exactly one YAML document from a string.
- from_
value - Converts a generic YAML
Valueinto a typed value. - lex
- Lexes YAML source into lossless tokens.
- parse_
cst - Parses a source buffer into a lossless CST node arena.
- resolve_
scalar - Resolves a decoded scalar value using the YAML 1.2 core schema.
- semantically_
equal - Compares two YAML nodes using RFC 6902 JSON-value equality.
- to_
string - Serializes a value to a UTF-8 YAML string.
- to_
value - Converts a serializable value into a generic YAML
Value. - to_
writer - Serializes a value as one YAML document.
- tokens_
to_ string - Reconstructs source text from token spans.
Type Aliases§
- Parse
Error - Alias for parse errors until richer phase-specific errors are introduced.
- Result
- Result type used by this crate.
- Sequence
- A YAML sequence whose elements are
Values.
Derive Macros§
- YamlRt
- Derives typed YAML round-trip overlay implementations.