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 supportalloc(default): Enable allocation support (required for most features)embedded: Enable embedded systems optimizations and limitsparse-only: Only enable parsing, disable serializationstringify: Enable YAML stringification (requiresalloc)format-converters: Enable JSON, XML, TOML, Bencode convertersfile-io: Enable file I/O operations (requiresstd)
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§
- Array
Builder - Fluent builder for constructing Array nodes Builder for constructing Array nodes with a fluent API
- Buffer
Destination - Destination implementation for writing YAML data to a memory buffer
In-memory byte buffer destination (
Vec<u8>). - Buffer
Source - 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.
- Capacity
Hints - Capacity hints for optimizing allocations during parsing Capacity hints for optimizing allocations during parsing
- Common
Strings - Common pre-interned strings for typical YAML keys Common strings that frequently appear in YAML documents
- Document
Stats - Document statistics for performance analysis Statistics about a YAML document structure
- Fast
Path Detector - Fast path detector for common YAML patterns Fast path detector for common YAML patterns
- File
Destination - Destination implementation for writing YAML data to a file File output destination writing to a buffered file on disk (32KB write buffer).
- File
Source - Source implementation for reading YAML data from a file File
- Interned
String - Reference-counted interned string for memory deduplication A reference-counted interned string
- Interner
Stats - 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
- Mapping
Builder - Fluent builder for constructing Mapping nodes Builder for constructing Mapping nodes with a fluent API
- Node
Builder - Memory-efficient node builder that reuses allocations Memory-efficient node builder that reuses allocations
- Node
Iterator - Iterator for traversing node trees Iterator for traversing a Node tree
- Node
Path - Path for accessing nested nodes Path for accessing nested nodes
- Node
Stream - Stream processor for efficient large document handling Stream processor for efficient large document handling
- Performance
Optimizer - 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
- Simple
Interner - Simple single-threaded string interner Simple non-thread-safe interner for single-threaded use
- String
Interner - 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§
- Block
Style - 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.
- Path
Segment - Path segment (key or index) for node access Path-based node access
- Quote
Type - Quote type for string nodes Represents how a string was quoted in the source YAML
- Traversal
Order - Traversal order for iterating through nodes Traversal order for iterating through a Node tree
Traits§
- Node
Index - Trait for indexing into a Node safely (by index or key)
Helper trait abstracting sequence index (
usize) and mapping key (&str) lookup forNode. - Node
Iterator Ext - 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
Nodeto any [IDestination]. - to_
string - Serialize a YAML
Nodeinto an ownedString. - to_vec
- Serialize a YAML
Nodeinto 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§
- Zero
Copy Str - String pool for deduplicating common strings during parsing Zero-copy string wrapper Zero-copy string wrapper that borrows when possible