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

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 YamlRoundTrip for typed round-trip overlays. The optional serde feature re-exports serialization and deserialization APIs for conversions where presentation preservation is not required.

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.
Node
Lossless syntax node produced by the CST parser.
NodeId
Identifier for a node stored inside a crate::YamlDoc.
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.

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.
YamlEventKind
Semantic YAML event kinds.
YamlScalarStyle
YAML scalar spelling.

Constants§

TARGET_YAML_VERSION
YAML version targeted by this workspace.

Traits§

FromYamlDoc
Converts a YAML document into a typed overlay.
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.
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.
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_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.

Derive Macros§

YamlRoundTrip
Derives typed YAML round-trip overlay implementations.