Expand description
Event-to-AST loader.
Consumes the event stream from crate::parse_events and builds a
Vec<Document<Span>>.
Two modes are available:
- Lossless (default): alias references are kept as
Node::Aliasnodes — no expansion, safe for untrusted input without any expansion limit. - Resolved: aliases are expanded inline. An expansion-node counter guards against alias bombs (Billion Laughs attack).
Security controls (all active in both modes unless noted):
max_nesting_depth— caps sequence/mapping nesting to prevent stack exhaustion (default 512).max_anchors— caps distinct anchor registrations to bound anchor-map memory (default 10 000).max_expanded_nodes— caps total nodes produced by alias expansion in resolved mode only (default 1 000 000).
§Accepted risks
expand_node does not detect the case where an anchor-within-expansion
references a previously defined anchor, forming an indirect cycle not
caught by the in_progress set until the second traversal. This
limitation exists in the old loader and is acceptable in the LSP context
where Lossless mode is the default. The expanded_nodes volume limit
provides the backstop.
Structs§
- Loader
- A configured YAML loader.
- Loader
Builder - Builder for configuring and creating a
Loader. - Loader
Options - Security and behaviour options for the loader.
Enums§
- Load
Error - Errors produced by the loader.
- Load
Mode - Loader mode — controls how alias references are handled.
Functions§
- load
- Load YAML text using lossless mode and default security limits.