Enum strict_yaml_rust::strict_yaml::StrictYaml
source · [−]Expand description
A YAML node is stored as this Yaml
enumeration, which provides an easy way to
access your YAML document.
Examples
use strict_yaml_rust::StrictYaml;
let foo = StrictYaml::from_str("-123"); // convert the string to the appropriate YAML type
assert_eq!(foo.as_str().unwrap(), "-123");
// iterate over an Array
let vec = StrictYaml::Array(vec![StrictYaml::String("1".into()), StrictYaml::String("2".into())]);
for v in vec.as_vec().unwrap() {
assert!(v.as_str().is_some());
}
Variants
String(String)
YAML scalar.
Array(Array)
YAML array, can be accessed as a Vec
.
Hash(Hash)
YAML hash, can be accessed as a LinkedHashMap
.
Iteration order will match the order of insertion into the map.
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
.
Implementations
sourceimpl StrictYaml
impl StrictYaml
pub fn as_str(&self) -> Option<&str>
pub fn as_hash(&self) -> Option<&Hash>
pub fn as_vec(&self) -> Option<&Array>
pub fn into_string(self) -> Option<String>
pub fn into_hash(self) -> Option<Hash>
pub fn into_vec(self) -> Option<Array>
pub fn is_badvalue(&self) -> bool
pub fn is_array(&self) -> bool
sourceimpl StrictYaml
impl StrictYaml
pub fn from_str(v: &str) -> StrictYaml
Trait Implementations
sourceimpl Clone for StrictYaml
impl Clone for StrictYaml
sourcefn clone(&self) -> StrictYaml
fn clone(&self) -> StrictYaml
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for StrictYaml
impl Debug for StrictYaml
sourceimpl Hash for StrictYaml
impl Hash for StrictYaml
sourceimpl<'a> Index<&'a str> for StrictYaml
impl<'a> Index<&'a str> for StrictYaml
type Output = StrictYaml
type Output = StrictYaml
The returned type after indexing.
sourcefn index(&self, idx: &'a str) -> &StrictYaml
fn index(&self, idx: &'a str) -> &StrictYaml
Performs the indexing (container[index]
) operation. Read more
sourceimpl Index<usize> for StrictYaml
impl Index<usize> for StrictYaml
type Output = StrictYaml
type Output = StrictYaml
The returned type after indexing.
sourcefn index(&self, idx: usize) -> &StrictYaml
fn index(&self, idx: usize) -> &StrictYaml
Performs the indexing (container[index]
) operation. Read more
sourceimpl IntoIterator for StrictYaml
impl IntoIterator for StrictYaml
sourceimpl Ord for StrictYaml
impl Ord for StrictYaml
sourceimpl PartialEq<StrictYaml> for StrictYaml
impl PartialEq<StrictYaml> for StrictYaml
sourcefn eq(&self, other: &StrictYaml) -> bool
fn eq(&self, other: &StrictYaml) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &StrictYaml) -> bool
fn ne(&self, other: &StrictYaml) -> bool
This method tests for !=
.
sourceimpl PartialOrd<StrictYaml> for StrictYaml
impl PartialOrd<StrictYaml> for StrictYaml
sourcefn partial_cmp(&self, other: &StrictYaml) -> Option<Ordering>
fn partial_cmp(&self, other: &StrictYaml) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for StrictYaml
impl StructuralEq for StrictYaml
impl StructuralPartialEq for StrictYaml
Auto Trait Implementations
impl RefUnwindSafe for StrictYaml
impl Send for StrictYaml
impl Sync for StrictYaml
impl Unpin for StrictYaml
impl UnwindSafe for StrictYaml
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more