Enum gazetta_core::yaml::Yaml [] [src]

pub enum Yaml {
    Real(String),
    Integer(i64),
    String(String),
    Boolean(bool),
    Array(Vec<Yaml>),
    Hash(BTreeMap<Yaml, Yaml>),
    Alias(usize),
    Null,
    BadValue,
}

An YAML node is store as this Yaml enumeration, it provides an easy way to access your YAML document.

Examples

use yaml_rust::Yaml;
let foo = Yaml::from_str("-123"); // convert the string to the appropriate YAML type
assert_eq!(foo.as_i64().unwrap(), -123);

// iterator over an Array
let vec = Yaml::Array(vec![Yaml::Integer(1), Yaml::Integer(2)]);
for v in vec.as_vec().unwrap() {
    assert!(v.as_i64().is_some());
}

Variants

float types are stored as String, and parsed on demand. Note that f64 does NOT implement Eq trait and can NOT be stored in BTreeMap

Yaml int is stored as i64.

Yaml scalar.

Yaml bool, e.g. true or false.

Yaml array, can be access as a Vec.

Yaml hash, can be access as a BTreeMap.

Alias, not fully supported yet.

Yaml bool, e.g. null or ~.

Access non-exist node by Index trait will return BadValue. This simplifies error handling of user. Invalid type conversion also return BadValue.

Methods

impl Yaml
[src]

Trait Implementations

impl Clone for Yaml
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialOrd<Yaml> for Yaml
[src]

impl Ord for Yaml
[src]

impl Eq for Yaml
[src]

impl PartialEq<Yaml> for Yaml
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Debug for Yaml
[src]

Formats the value using the given formatter.

impl<'a> Index<&'a str> for Yaml
[src]

impl Index<usize> for Yaml
[src]