taffy/value
The YamlValue type and direct accessors. Most users want the
re-exports on the top-level taffy module; this module is exposed for
pattern-matching (value.Null, value.Mapping(_)) and for direct
YamlValue construction in tests.
Types
Note on Mapping: pairs are stored in YAML insertion order. Taffy does
not currently reject duplicate keys (YAML 1.2 says it should — this is a
known gap). When duplicates exist, get / get_path return the first
match while as_dict collapses to last-wins.
pub type YamlValue {
Null
Bool(Bool)
Int(Int)
Float(Float)
String(String)
Sequence(List(YamlValue))
Mapping(List(#(String, YamlValue)))
}
Constructors
Values
pub fn as_bool(value: YamlValue) -> option.Option(Bool)
pub fn as_float(value: YamlValue) -> option.Option(Float)
pub fn as_int(value: YamlValue) -> option.Option(Int)
pub fn as_list(
value: YamlValue,
) -> option.Option(List(YamlValue))
pub fn as_pairs(
value: YamlValue,
) -> option.Option(List(#(String, YamlValue)))
pub fn as_string(value: YamlValue) -> option.Option(String)
pub fn get(
value: YamlValue,
key: String,
) -> option.Option(YamlValue)
pub fn index(
value: YamlValue,
idx: Int,
) -> option.Option(YamlValue)
pub fn size(value: YamlValue) -> Int
Count the total number of nodes in a value tree (including the root). Used by the parser to budget alias expansion against billion-laughs attacks; exposed so callers can apply their own size policies.