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 moresourceimpl 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 moresourceimpl 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 moresourceimpl IntoIterator for StrictYaml
impl IntoIterator for StrictYaml
sourceimpl Ord for StrictYaml
impl Ord for StrictYaml
sourcefn cmp(&self, other: &StrictYaml) -> Ordering
fn cmp(&self, other: &StrictYaml) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 · sourcefn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: Sized + PartialOrd<Self>,
Restrict a value to a certain interval. Read more
sourceimpl PartialEq<StrictYaml> for StrictYaml
impl PartialEq<StrictYaml> for StrictYaml
sourcefn eq(&self, other: &StrictYaml) -> bool
fn eq(&self, other: &StrictYaml) -> bool
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>
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 moreimpl 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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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