Skip to main content

Crate yaml_rt

Crate yaml_rt 

Source
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.
FragmentError
Failure to parse, validate, or render a YAML fragment.
JsonPointer
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.
PointerError
Structured JSON Pointer parse or resolution error.
ReferenceToken
One decoded RFC 6901 reference token.
ReservedDirective
Parsed reserved directive metadata.
ScalarResolveError
Failure to resolve a scalar according to the YAML core schema.
SemanticValueError
Failure while projecting YAML nodes into the JSON-compatible data model.
Serializer
A YAML serializer writing one or more documents to an io::Write sink.
Source
Original YAML input plus line-start metadata.
Span
A byte span inside a Source.
TagDirective
Parsed %TAG directive metadata.
Token
Lexical token preserving its exact source span.
YamlDirective
Parsed %YAML directive metadata.
YamlDoc
A source-preserving YAML document.
YamlEditError
Failure while applying a pointer-addressed YAML edit.
YamlError
Error type for YAML parsing, semantic lookup, typed overlays, and emission.
YamlEvent
Semantic YAML event produced by the parser.
YamlEvents
On-demand iterator over semantic YAML events.
YamlFragment
A parsed YAML value document containing exactly one root node.
YamlNumber
An exact, finite YAML number normalized for semantic comparison.
YamlPatch
A parsed sequence of RFC 6902-style operations over YAML values.
YamlPatchError
Failure while parsing or applying a YAML patch.

Enums§

CollectionStyle
YAML collection spelling.
DiagnosticKind
Diagnostic phase.
MappingEntryStyle
Formatting controls for inserting a block mapping entry.
NodeKind
Node kinds emitted by the CST parser.
NonFiniteFloat
A non-finite YAML float, which is outside the JSON-compatible data model.
PointerErrorKind
Classification of a JSON Pointer parse or resolution failure.
ResolvedScalar
YAML 1.2 core-schema interpretation of a scalar.
SemanticKind
Semantic interpretation attached to a lossless CST node.
TokenKind
Token kinds emitted by the lossless lexer.
Value
A loosely typed YAML value.
YamlEventKind
Semantic YAML event kinds.
YamlPatchErrorKind
Classification of a YAML patch failure.
YamlPatchOperation
One YAML patch operation.
YamlScalarStyle
YAML scalar spelling.

Constants§

TARGET_YAML_VERSION
YAML version targeted by this workspace.

Traits§

FromYamlDoc
Converts a YAML document into a typed overlay.
Index
A sealed type that can index a YAML Value or Mapping.
ToYamlDoc
Applies a typed overlay back to a YAML document as minimal patches.
ToYamlFragment
Formats a typed value as a YAML fragment for parent-aware insertions.
YamlFlatten
Reads and writes a field flattened into its containing YAML mapping.
YamlValue
Reads and writes individual YAML node values.

Functions§

events_to_test_string
Renders YAML events in the YAML Test Suite test.event format.
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 Value into 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§

ParseError
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.