Expand description
Pure-Rust YAML parser, emitter, and Serde integration for configuration-shaped YAML.
The preview API focuses on YAML 1.2 parser events, pull-based event and
document streaming, loaded document trees with default merge-key expansion,
explicit and directive-driven YAML 1.1 scalar construction options, serde_yaml-style
Value/Mapping/Number workflows, typed Serde reads, structural writes,
explicit emission fidelity tiers, and line/column diagnostics. See
docs/MIGRATION.md and docs/COMPATIBILITY.md for the current adoption
contract and intentional non-goals.
use serde::Deserialize;
#[derive(Deserialize)]
struct Config {
name: String,
}
let config: Config = saneyaml::from_str("name: api\n")?;
assert_eq!(config.name, "api");Re-exports§
pub use lossless::AliasId;pub use lossless::AnchorId;pub use lossless::ConfigEditor;pub use lossless::ConfigPath;pub use lossless::LosslessAlias;pub use lossless::LosslessAnchor;pub use lossless::LosslessDocument;pub use lossless::LosslessEdit;pub use lossless::LosslessEffectiveMappingEntry;pub use lossless::LosslessEffectiveMappingSource;pub use lossless::LosslessNode;pub use lossless::LosslessNodeKind;pub use lossless::LosslessStream;pub use lossless::LosslessTrivia;pub use lossless::LosslessTriviaKind;pub use lossless::NodeId;pub use lossless::PathSegment;pub use lossless::edit;pub use lossless::edit_file;pub use lossless::parse_lossless;pub use lossless::parse_lossless_bytes;pub use lossless::parse_lossless_bytes_with_options;pub use lossless::parse_lossless_with_options;
Modules§
- lossless
- Source-backed lossless YAML stream and graph identity API.
- mapping
- Mapping types and iterators for YAML
Mapping. - stream
- Pull-based YAML event and document streaming APIs.
- value
- Value-oriented API matching the
serde_yaml::valuemodule shape. - with
- Serde helper modules matching selected
serde_yaml::withpaths. Serde helper modules matching selectedserde_yaml::withpaths.
Structs§
- Borrowed
Node - Spanless YAML document tree that can borrow scalar strings from the input.
- Borrowed
Tagged Node - Spanless borrowed YAML tagged node.
- Date
- Date component of a YAML 1.1
Timestamp. - Deserializer
- Streaming Serde deserializer over one or more YAML documents.
- Diagnostic
- Structured diagnostic payload for a YAML error.
- Document
Stream - Pull-based iterator over semantic YAML documents.
- Emit
Options - YAML emission options.
- Error
- Error type returned by all public YAML APIs.
- Error
Path - Path to a value inside a YAML document.
- Event
Anchor - Anchor metadata captured from a raw event.
- Event
Document Directives - Directive metadata attached to a document start event.
- Event
Meta - Anchor and tag metadata attached to a raw event.
- Event
Stream - Pull-based iterator over raw YAML parser events.
- Event
Tag - Tag metadata captured from a raw event.
- Event
TagDirective %TAGdirective captured from a document header.- Event
Yaml Version - YAML version directive captured from a document header.
- Load
Options - Options for loading YAML into constructed trees or Serde values.
- Location
- A compact source location returned by
Error::location. - Mapping
- Ordered YAML mapping with
Valuekeys and values. - Node
- Spanful YAML document tree node produced by the parser.
- Occupied
Entry - Occupied entry in a
Mapping. - Related
Diagnostic - Additional source context associated with a primary diagnostic.
- Scalar
Source - Original scalar spelling retained for string-target deserialization.
- Serializer
- Streaming YAML serializer for writing one document at a time.
- Source
Diagnostic - Display wrapper for explicit source-context diagnostic rendering.
- Source
Render Options - Options for source-context diagnostic rendering.
- Span
- A byte span plus one-based line and column for a YAML source location.
- Tag
- Parsed YAML tag handle and suffix.
- Tagged
Node - Spanful YAML tagged node.
- Tagged
Value - Spanless tagged YAML value.
- Time
- Time component of a YAML 1.1
Timestamp. - Time
Zone Offset - UTC offset component of a YAML 1.1
Timestamp. - Timestamp
- YAML 1.1 timestamp value parsed from
!!timestampscalars. - Vacant
Entry - Vacant entry in a
Mapping.
Enums§
- Block
Scalar Style - Block scalar style policy for multiline string scalars.
- Borrowed
Node Value - Spanless borrowed YAML node payload.
- Collection
Style - Collection style preserved by
parse_events. - Emit
Collection Style - Collection layout policy.
- Emit
Fidelity - Emission fidelity mode.
- Entry
- Entry view into a
Mapping. - Enum
Representation - Serde enum representation used by option-aware writers.
- Error
Category - Broad, stable category for a YAML error.
- Error
Path Segment - One segment of an
ErrorPath. - Event
- A raw parser event emitted while reading a YAML stream.
- KeyOrder
- Mapping key ordering policy.
- Node
Value - Spanful YAML node payload.
- Number
- YAML number representation.
- Scalar
Quote Style - Scalar quote policy for inline string scalars.
- Scalar
Style - Scalar style preserved by
parse_events. - Schema
- Scalar construction schema used by tree and Serde loading.
- Value
- Spanless YAML value tree used by Serde-facing APIs.
Constants§
- DEFAULT_
ALIAS_ EXPANSION_ FACTOR - Default alias expansion budget multiplier per input byte.
- DEFAULT_
MAX_ COLLECTION_ ITEMS - Default maximum number of entries accepted in one sequence or mapping.
- DEFAULT_
MAX_ INPUT_ BYTES - Default maximum YAML input size accepted by loading entrypoints.
- DEFAULT_
MAX_ NESTING_ DEPTH - Default maximum constructed YAML nesting depth accepted by loading entrypoints.
- DEFAULT_
MAX_ SCALAR_ BYTES - Default maximum resolved scalar size accepted by loading entrypoints.
- DEFAULT_
MIN_ ALIAS_ EXPANSION_ NODES - Minimum alias expansion budget used by default loading options.
Traits§
Functions§
- from_
documents_ reader - Reads all bytes from a reader and deserializes every YAML document.
- from_
documents_ slice - Deserializes every document in a UTF-8 YAML stream from bytes.
- from_
documents_ str - Deserializes every document in a YAML stream from a string.
- from_
node - Deserializes from an already parsed spanful
Node. - from_
reader - Reads all bytes from a reader and deserializes one YAML document.
- from_
slice - Deserializes a single UTF-8 YAML document from bytes.
- from_
str - Deserializes a single YAML document from a string.
- from_
value - Deserializes from a spanless YAML
Value. - parse_
borrowed_ documents - Parses all documents into spanless trees that can borrow scalar strings from
input. - parse_
bytes - Parses a single YAML document from UTF-8 bytes.
- parse_
documents - Parses all documents in a YAML stream.
- parse_
events - Parses a YAML stream and returns raw structural events.
- parse_
str - Parses a single YAML document from a string.
- stream_
documents - Creates a pull-based stream of parsed YAML documents from a YAML string.
- stream_
documents_ reader - Reads YAML bytes and creates a pull-based stream of parsed YAML documents.
- stream_
documents_ slice - Creates a pull-based stream of parsed YAML documents from UTF-8 YAML bytes.
- stream_
events - Creates a pull-based stream of raw parser events from a YAML string.
- stream_
events_ reader - Reads YAML bytes and creates a pull-based stream of raw parser events.
- stream_
events_ slice - Creates a pull-based stream of raw parser events from UTF-8 YAML bytes.
- to_
string - Serializes a value into a YAML string.
- to_
string_ with_ options - Serializes a value into a YAML string using explicit emission options.
- to_
value - Converts a serializable value into a YAML
Value. - to_
writer - Serializes a value as YAML and writes it to an output sink.
- to_
writer_ with_ options - Serializes a value as YAML using explicit emission options and writes it to an output sink.