Skip to main content

Crate saneyaml

Crate saneyaml 

Source
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::value module shape.
with
Serde helper modules matching selected serde_yaml::with paths. Serde helper modules matching selected serde_yaml::with paths.

Structs§

BorrowedNode
Spanless YAML document tree that can borrow scalar strings from the input.
BorrowedTaggedNode
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.
DocumentStream
Pull-based iterator over semantic YAML documents.
EmitOptions
YAML emission options.
Error
Error type returned by all public YAML APIs.
ErrorPath
Path to a value inside a YAML document.
EventAnchor
Anchor metadata captured from a raw event.
EventDocumentDirectives
Directive metadata attached to a document start event.
EventMeta
Anchor and tag metadata attached to a raw event.
EventStream
Pull-based iterator over raw YAML parser events.
EventTag
Tag metadata captured from a raw event.
EventTagDirective
%TAG directive captured from a document header.
EventYamlVersion
YAML version directive captured from a document header.
LoadOptions
Options for loading YAML into constructed trees or Serde values.
Location
A compact source location returned by Error::location.
Mapping
Ordered YAML mapping with Value keys and values.
Node
Spanful YAML document tree node produced by the parser.
OccupiedEntry
Occupied entry in a Mapping.
RelatedDiagnostic
Additional source context associated with a primary diagnostic.
ScalarSource
Original scalar spelling retained for string-target deserialization.
Serializer
Streaming YAML serializer for writing one document at a time.
SourceDiagnostic
Display wrapper for explicit source-context diagnostic rendering.
SourceRenderOptions
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.
TaggedNode
Spanful YAML tagged node.
TaggedValue
Spanless tagged YAML value.
Time
Time component of a YAML 1.1 Timestamp.
TimeZoneOffset
UTC offset component of a YAML 1.1 Timestamp.
Timestamp
YAML 1.1 timestamp value parsed from !!timestamp scalars.
VacantEntry
Vacant entry in a Mapping.

Enums§

BlockScalarStyle
Block scalar style policy for multiline string scalars.
BorrowedNodeValue
Spanless borrowed YAML node payload.
CollectionStyle
Collection style preserved by parse_events.
EmitCollectionStyle
Collection layout policy.
EmitFidelity
Emission fidelity mode.
Entry
Entry view into a Mapping.
EnumRepresentation
Serde enum representation used by option-aware writers.
ErrorCategory
Broad, stable category for a YAML error.
ErrorPathSegment
One segment of an ErrorPath.
Event
A raw parser event emitted while reading a YAML stream.
KeyOrder
Mapping key ordering policy.
NodeValue
Spanful YAML node payload.
Number
YAML number representation.
ScalarQuoteStyle
Scalar quote policy for inline string scalars.
ScalarStyle
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§

Index
A key type that can index into a YAML Value.

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.

Type Aliases§

Result
Result alias used by this crate.
Sequence
YAML sequence containing spanless Value elements.