Enum amethyst_config::Yaml []

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

A YAML node is stored as this Yaml enumeration, which 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);

// iterate 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

Real(String)

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.

Integer(i64)

YAML int is stored as i64.

String(String)

YAML scalar.

Boolean(bool)

YAML bool, e.g. true or false.

Array(Vec<Yaml>)

YAML array, can be accessed as a Vec.

Hash(BTreeMap<YamlYaml>)

YAML hash, can be accessed as a BTreeMap.

If the order of keys is meaningful, enable the preserve_order feature to store hashes as a LinkedHashMap intead of BTreeMap. When using a LinkedHashMap, the itertion order will match the order of insertion into the map.

yaml-rust = { version = "*", features = ["preserve_order"] }
Alias(usize)

Alias, not fully supported yet.

Null

YAML null, e.g. null or ~.

BadValue

Accessing a nonexistent node via the Index trait returns BadValue. This simplifies error handling in the calling code. Invalid type conversion also returns BadValue.

Methods

impl Yaml

fn as_bool(&self) -> Option<bool>

fn as_i64(&self) -> Option<i64>

fn as_str(&self) -> Option<&str>

fn as_hash(&self) -> Option<&BTreeMap<YamlYaml>>

fn as_vec(&self) -> Option<&Vec<Yaml>>

fn is_null(&self) -> bool

fn is_badvalue(&self) -> bool

fn as_f64(&self) -> Option<f64>

impl Yaml

fn from_str(v: &str) -> Yaml

Trait Implementations

impl Hash for Yaml

fn hash<__H>(&self, __arg_0: &mut __H) where __H: Hasher

Feeds this value into the state given, updating the hasher as necessary.

fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0

Feeds a slice of this type into the state provided.

impl Ord for Yaml

fn cmp(&self, __arg_0: &Yaml) -> Ordering

This method returns an Ordering between self and other. Read more

impl Eq for Yaml

impl Debug for Yaml

fn fmt(&self, __arg_0: &mut Formatter) -> Result<()Error>

Formats the value using the given formatter.

impl PartialOrd<Yaml> for Yaml

fn partial_cmp(&self, __arg_0: &Yaml) -> Option<Ordering>

fn lt(&self, __arg_0: &Yaml) -> bool

fn le(&self, __arg_0: &Yaml) -> bool

fn gt(&self, __arg_0: &Yaml) -> bool

fn ge(&self, __arg_0: &Yaml) -> bool

impl PartialEq<Yaml> for Yaml

fn eq(&self, __arg_0: &Yaml) -> bool

fn ne(&self, __arg_0: &Yaml) -> bool

impl Clone for Yaml

fn clone(&self) -> Yaml

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)
1.0.0

Performs copy-assignment from source. Read more

impl<'a> Index<&'a str> for Yaml

type Output = Yaml

fn index(&self, idx: &'a str) -> &Yaml

impl Index<usize> for Yaml

type Output = Yaml

fn index(&self, idx: usize) -> &Yaml