Skip to main content

Crate babbel_yaml

Crate babbel_yaml 

Source
Expand description

§babbel_yaml

A fast, modular YAML 1.2 parser and emitter in pure Rust, supporting anchors, aliases, tags, multi-document streams, and embedded resource constraints.

§Key Capabilities

  • Fast YAML 1.2 DOM parsing and document navigation
  • Anchor and alias resolution with cycle detection
  • File and buffer streaming I/O abstractions powered by babbel_core
  • Pretty-printing and custom block scalar formatting
  • Unicode-aware file handling and BOM detection

Minimum supported Rust version: 1.88.0

§Feature Flags

  • std (default): Enable standard library support
  • alloc (default): Enable allocation support (required for most features)
  • embedded: Enable embedded systems optimizations and limits
  • parse-only: Only enable parsing, disable serialization
  • stringify: Enable YAML stringification (requires alloc)
  • format-converters: Enable JSON, XML, TOML, Bencode converters
  • file-io: Enable file I/O operations (requires std)

Re-exports§

pub use engine::YamlEngine;
pub use error::ErrorKind;
pub use error::YamlError;
pub use error::enhanced::EnhancedError;
pub use error::enhanced::ErrorCode;
pub use error::enhanced::ErrorSuggestion;
pub use error::enhanced::Span;
pub use error::enhanced::SuggestionBuilder;
pub use error::recovery::ErrorCollection;
pub use error::recovery::ParserState;
pub use error::recovery::RecoveryContext;
pub use error::recovery::RecoveryHandler;
pub use error::recovery::RecoveryStrategy;
pub use parser::config::ParserConfig;
pub use parser::config::ParserConfigBuilder;
pub use parser::document::parse;
pub use stringify::bencode::stringify as to_bencode;
pub use stringify::default::stringify;
pub use stringify::json::stringify as to_json;
pub use stringify::json::stringify_pretty as to_json_pretty;
pub use stringify::toml::stringify as to_toml;
pub use stringify::toml::stringify_pretty as to_toml_pretty;
pub use stringify::xml::stringify as to_xml;
pub use stringify::xml::stringify_pretty as to_xml_pretty;
pub use validation::engine::SchemaValidator;
pub use validation::engine::ValidationContext;
pub use validation::schema::ArraySchema;
pub use validation::schema::ObjectSchema;
pub use validation::schema::PropertySchema;
pub use validation::schema::Schema;
pub use validation::schema::SchemaType;
pub use validation::validators::CustomValidator;
pub use validation::validators::EnumValidator;
pub use validation::validators::LengthValidator;
pub use validation::validators::PatternValidator;
pub use validation::validators::RangeValidator;
pub use validation::validators::RequiredValidator;
pub use validation::validators::TypeValidator;
pub use validation::validators::ValidationResult;
pub use validation::validators::Validator;
pub use stringify::serializer::Serializer;
pub use stringify::serializer::SerializerRegistry;
pub use stringify::serializer::TaggedSerializer;
pub use stringify::serializer::TypeSerializer;
pub use stringify::streaming::StreamingSerializer;
pub use testing::fuzzing::FuzzResult;
pub use testing::fuzzing::FuzzRng;
pub use testing::fuzzing::YamlFuzzer;
pub use testing::fuzzing::fuzz_parse;
pub use testing::fuzzing::fuzz_roundtrip;
pub use testing::property::Property;
pub use testing::property::PropertyResult;
pub use testing::property::PropertySuite;
pub use testing::safety::MemoryStats;
pub use testing::safety::SafetyAudit;
pub use testing::safety::SafetyIssue;
pub use testing::safety::audit_node;
pub use testing::safety::calculate_memory_stats;
pub use devtools::debug::DebugAssert;
pub use devtools::debug::DebugContext;
pub use devtools::debug::DebugLevel;
pub use devtools::debug::NodeDebugger;
pub use devtools::diff::Diff;
pub use devtools::diff::DiffResult;
pub use devtools::diff::DiffType;
pub use devtools::diff::diff_nodes;
pub use devtools::inspect::NodeInfo;
pub use devtools::inspect::NodeType;
pub use devtools::inspect::find_by_type;
pub use devtools::inspect::has_anchor;
pub use devtools::inspect::has_tag;
pub use devtools::inspect::node_depth;
pub use devtools::inspect::node_size;
pub use devtools::inspect::node_summary;
pub use devtools::inspect::node_type;
pub use devtools::inspect::print_tree;
pub use devtools::trace::TracedTimer;
pub use devtools::trace::TraceEntry;
pub use devtools::trace::TraceEvent;
pub use devtools::trace::TraceGuard;
pub use devtools::trace::Tracer;

Modules§

devtools
Module for developer tools (debugging, inspection, diffing, tracing) YAML Developer Tools Module
embedded
Module for embedded systems support Embedded Systems Support Module
engine
Format engine implementation adhering to OCP and DIP YAML Format Engine adhering to OCP and DIP.
error
Module defining error types and handling for YAML operations. YAML Error Handling Module
parser
YAML Parser Module
stringify
Module implementing YAML parsing and value extraction Module for converting YAML structures to formatted strings YAML Stringification Modules
test_helpers
Common test helpers for integration/unit tests Test Helpers for YAML Library
testing
Module for testing infrastructure (fuzzing, property testing, safety) YAML Library Testing Module
validation
Module for YAML validation and schema support Validation and Schema Support for YAML Library

Macros§

anchors_debug
collection_size_check
Macro to check collection size and return error if exceeded.
combined_loop_guard
Combined guard for loops that build collections.
lexer_debug
loop_guard_check
Macro to check loop iteration count and return error if exceeded.
loop_guard_init
Macro to create and check loop iteration guard.

Structs§

ArrayBuilder
Fluent builder for constructing Array nodes Builder for constructing Array nodes with a fluent API
BufferDestination
Destination implementation for writing YAML data to a memory buffer In-memory byte buffer destination (Vec<u8>).
BufferSource
Source implementation for reading YAML data from a memory buffer A memory buffer implementation for reading JSON data from bytes. Provides functionality to traverse and read byte content from memory.
CapacityHints
Capacity hints for optimizing allocations during parsing Capacity hints for optimizing allocations during parsing
CommonStrings
Common pre-interned strings for typical YAML keys Common strings that frequently appear in YAML documents
DocumentStats
Document statistics for performance analysis Statistics about a YAML document structure
FastPathDetector
Fast path detector for common YAML patterns Fast path detector for common YAML patterns
FileDestination
Destination implementation for writing YAML data to a file File output destination writing to a buffered file on disk (32KB write buffer).
FileSource
Source implementation for reading YAML data from a file File
InternedString
Reference-counted interned string for memory deduplication A reference-counted interned string
InternerStats
Statistics about string interning performance Statistics about string interning
LazyTag
Lazy tag that defers type coercion until accessed Lazy tag that defers type coercion until accessed
MappingBuilder
Fluent builder for constructing Mapping nodes Builder for constructing Mapping nodes with a fluent API
NodeBuilder
Memory-efficient node builder that reuses allocations Memory-efficient node builder that reuses allocations
NodeIterator
Iterator for traversing node trees Iterator for traversing a Node tree
NodePath
Path for accessing nested nodes Path for accessing nested nodes
NodeStream
Stream processor for efficient large document handling Stream processor for efficient large document handling
PerformanceOptimizer
Performance optimizer combining multiple optimization strategies Performance optimizer that combines multiple optimization strategies
Profiler
Performance profiler for measuring multiple operations Performance profiler for measuring multiple operations
SetBuilder
Fluent builder for constructing Set nodes Builder for constructing Set nodes with a fluent API
SimpleInterner
Simple single-threaded string interner Simple non-thread-safe interner for single-threaded use
StringInterner
Thread-safe string interner with read-write lock String interner for deduplicating strings
Timer
Simple timer for measuring operation duration Simple timer for measuring operation duration

Enums§

BlockStyle
Block style for string nodes Represents block/folded style for YAML string nodes
Format
This enum represents different Unicode text file formats with their corresponding byte order marks (BOM) Represents different Unicode text file formats with their corresponding byte order marks (BOM).
Node
Core data structure representing a YAML node in the parsed tree A node in the YAML data structure that can represent different types of values.
Numeric
Core data structure representing a numeric value node in the parsed tree Represents different numeric types that can be stored in a YAML node Represents different numeric types that can be stored in AST nodes across format representations.
PathSegment
Path segment (key or index) for node access Path-based node access
QuoteType
Quote type for string nodes Represents how a string was quoted in the source YAML
TraversalOrder
Traversal order for iterating through nodes Traversal order for iterating through a Node tree

Traits§

NodeIndex
Trait for indexing into a Node safely (by index or key) Helper trait abstracting sequence index (usize) and mapping key (&str) lookup for Node.
NodeIteratorExt
Extension trait for Node providing iterator methods Extension trait for Node to provide iterator methods

Functions§

compare_performance
Utility to compare performance of different approaches Utility to compare performance of different approaches
detect_format
This function detects the Unicode format of a text file by examining its byte order mark (BOM) Detects the Unicode format of a text file by examining its byte order mark (BOM).
from_bytes
Parse YAML from raw bytes using the default parser configuration.
from_source
Parse YAML from any streaming source. Canonical alias for parse.
from_str
Parse YAML from an in-memory string slice. Canonical alias for parse_string.
get_document
Returns the base node of document number n (0-based), reporting any errors. Returns the base node of document number n (0-based), reporting any errors.
get_number_of_documents
Returns the number of documents in a YAML stream represented by the Documents node. Returns the number of documents in a YAML stream represented by the Documents node.
make_node
Helper function to create a Node from any value that can be converted into a Node Create a Node from any value that can be converted into a Node
make_set
Helper function to create a Set node from a vector, ensuring uniqueness Create a Set Node from a vector of values, ensuring uniqueness
parse_file
Parse YAML from a file path using the default parser configuration.
parse_string
Parse YAML from an in-memory string using the default parser configuration.
parse_string_with_recovery
Parse YAML from a string while preparing for future error recovery support.
parse_with_config
Parse YAML from a string with a custom parser configuration.
read_file_to_string
This function reads a text file and returns its content as a String, handling different Unicode formats Reads a text file and returns its content as a normalized UTF-8 String, stripping BOM if present.
to_destination
Serialize a YAML Node to any [IDestination].
to_string
Serialize a YAML Node into an owned String.
to_vec
Serialize a YAML Node into a byte vector (Vec<u8>).
version
Returns the current version of the YAML library Returns the current version of the package as specified in Cargo.toml.
write_file_from_string
This function writes a string to a file in the specified Unicode format Writes a string to a file in the specified Unicode format, prepending the corresponding BOM.

Type Aliases§

ZeroCopyStr
String pool for deduplicating common strings during parsing Zero-copy string wrapper Zero-copy string wrapper that borrows when possible