Skip to main content

Value

Enum Value 

pub enum Value {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Sequence(Vec<Value>),
    Mapping(Mapping),
    Tagged(Box<TaggedValue>),
}
Expand description

Represents any valid YAML value.

Variants§

§

Null

Represents a YAML null value.

§

Bool(bool)

Represents a YAML boolean.

§

Number(Number)

Represents a YAML number (integer or float).

§

String(String)

Represents a YAML string.

§

Sequence(Vec<Value>)

Represents a YAML sequence (array).

§

Mapping(Mapping)

Represents a YAML mapping (object).

§

Tagged(Box<TaggedValue>)

Represents a tagged YAML value.

Implementations§

§

impl Value

pub fn is_null(&self) -> bool

Returns true if the value is Value::Null.

§Examples
use noyalib::Value;
assert!(Value::Null.is_null());
assert!(!Value::from(false).is_null());

pub fn is_bool(&self) -> bool

Returns true if the value is a boolean.

§Examples
use noyalib::Value;
assert!(Value::from(true).is_bool());
assert!(!Value::from(1_i64).is_bool());

pub fn is_number(&self) -> bool

Returns true if the value is a number (integer or float).

§Examples
use noyalib::Value;
assert!(Value::from(42_i64).is_number());
assert!(Value::from(1.5).is_number());
assert!(!Value::from("42").is_number());

pub fn is_string(&self) -> bool

Returns true if the value is a string.

§Examples
use noyalib::Value;
assert!(Value::from("hello").is_string());
assert!(!Value::from(42_i64).is_string());

pub fn is_sequence(&self) -> bool

Returns true if the value is a sequence (YAML list).

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("[1, 2, 3]").unwrap();
assert!(v.is_sequence());

pub fn is_mapping(&self) -> bool

Returns true if the value is a mapping (YAML map).

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("a: 1\nb: 2\n").unwrap();
assert!(v.is_mapping());

pub fn is_tagged(&self) -> bool

Returns true if the value is tagged (custom YAML tag).

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("!Custom 'hello'\n").unwrap();
assert!(v.is_tagged());

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

Returns the value as a boolean if it is one.

§Examples
use noyalib::Value;
assert_eq!(Value::from(true).as_bool(), Some(true));
assert_eq!(Value::from("true").as_bool(), None);

pub fn as_null(&self) -> Option<()>

Returns Some(()) if the value is null, None otherwise.

§Examples
use noyalib::Value;
assert_eq!(Value::Null.as_null(), Some(()));
assert_eq!(Value::from(0_i64).as_null(), None);

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

Returns the value as an i64 if it is an integer.

Floats return None even when the underlying value is a whole number; the type tag is part of the test.

§Examples
use noyalib::Value;
assert_eq!(Value::from(42_i64).as_i64(), Some(42));
assert_eq!(Value::from(1.5).as_i64(), None);

pub fn as_u64(&self) -> Option<u64>

Returns the value as a u64 if it is a non-negative integer.

Negative integers return None. Floats also return None.

§Examples
use noyalib::Value;
assert_eq!(Value::from(42_i64).as_u64(), Some(42));
assert_eq!(Value::from(-1_i64).as_u64(), None);

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

Returns the value as an f64 if it is a number.

Integers are widened to f64 (with the usual i64 → f64 precision loss for magnitudes above 2^53).

§Examples
use noyalib::Value;
assert_eq!(Value::from(42_i64).as_f64(), Some(42.0));
assert_eq!(Value::from(1.5).as_f64(), Some(1.5));
assert_eq!(Value::from("42").as_f64(), None);

pub fn is_i64(&self) -> bool

Returns true if the value is an integer that fits in i64.

§Examples
use noyalib::Value;
assert!(Value::from(42_i64).is_i64());
assert!(!Value::from(1.5).is_i64());

pub fn is_u64(&self) -> bool

Returns true if the value is a non-negative integer that fits in u64.

§Examples
use noyalib::Value;
assert!(Value::from(42_i64).is_u64());
assert!(!Value::from(-1_i64).is_u64());

pub fn is_f64(&self) -> bool

Returns true if the value is a number (always convertible to f64).

§Examples
use noyalib::Value;
assert!(Value::from(42_i64).is_f64());
assert!(Value::from(1.5).is_f64());

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

Returns the value as a string slice if it is a string.

§Examples
use noyalib::Value;
assert_eq!(Value::from("hello").as_str(), Some("hello"));
assert_eq!(Value::from(42_i64).as_str(), None);

pub fn as_sequence(&self) -> Option<&Vec<Value>>

Returns the value as a sequence if it is one.

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("[1, 2, 3]").unwrap();
assert_eq!(v.as_sequence().map(|s| s.len()), Some(3));

pub fn as_sequence_mut(&mut self) -> Option<&mut Vec<Value>>

Returns the value as a mutable sequence if it is one.

§Examples
use noyalib::{from_str, Value};
let mut v: Value = from_str("[1, 2]").unwrap();
if let Some(seq) = v.as_sequence_mut() {
    seq.push(Value::from(3_i64));
}
assert_eq!(v.as_sequence().unwrap().len(), 3);

pub fn as_mapping(&self) -> Option<&Mapping>

Returns the value as a mapping if it is one.

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("a: 1\nb: 2\n").unwrap();
let m = v.as_mapping().unwrap();
assert_eq!(m.get("a").and_then(Value::as_i64), Some(1));

pub fn as_mapping_mut(&mut self) -> Option<&mut Mapping>

Returns the value as a mutable mapping if it is one.

§Examples
use noyalib::{from_str, Value};
let mut v: Value = from_str("a: 1\n").unwrap();
if let Some(m) = v.as_mapping_mut() {
    m.insert("b", Value::from(2_i64));
}
assert_eq!(v.as_mapping().unwrap().len(), 2);

pub fn as_tagged(&self) -> Option<&TaggedValue>

Returns the value as a tagged value if it is one.

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("!Custom 'hi'\n").unwrap();
let tv = v.as_tagged().unwrap();
assert_eq!(tv.tag().as_str(), "!Custom");

pub fn as_tagged_mut(&mut self) -> Option<&mut TaggedValue>

Returns the value as a mutable tagged value if it is one.

§Examples
use noyalib::{from_str, Tag, Value};
let mut v: Value = from_str("!A 'x'\n").unwrap();
if let Some(tv) = v.as_tagged_mut() {
    // mutate inner via value_mut
    *tv.value_mut() = Value::from("y");
}
assert_eq!(v.as_tagged().unwrap().value().as_str(), Some("y"));

pub fn get<I>(&self, index: I) -> Option<&Value>
where I: ValueIndex,

Index into a sequence or mapping.

Accepts a string key (for mappings) or a usize index (for sequences).

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("a: [1, 2, 3]\n").unwrap();
assert_eq!(v.get("a").unwrap().get(0).and_then(Value::as_i64), Some(1));

pub fn get_mut<I>(&mut self, index: I) -> Option<&mut Value>
where I: ValueIndex,

Mutably index into a sequence or mapping.

§Examples
use noyalib::{from_str, Value};
let mut v: Value = from_str("a: 1\n").unwrap();
if let Some(slot) = v.get_mut("a") {
    *slot = Value::from(2_i64);
}
assert_eq!(v.get("a").and_then(Value::as_i64), Some(2));

pub fn get_path(&self, path: &str) -> Option<&Value>

Access a nested value using a path string.

Supports dot notation for mappings and bracket notation for sequences:

  • "foo.bar" - access key “bar” in mapping “foo”
  • "items[0]" - access index 0 in sequence “items”
  • "items[0].name" - access key “name” in first element of sequence “items”
§Examples
use noyalib::{from_str, Value};

let yaml = r#"
server:
  host: localhost
  port: 8080
items:
  - name: first
  - name: second
"#;

let value: Value = from_str(yaml).unwrap();

assert_eq!(
    value.get_path("server.host").unwrap().as_str(),
    Some("localhost")
);
assert_eq!(value.get_path("server.port").unwrap().as_i64(), Some(8080));
assert_eq!(
    value.get_path("items[0].name").unwrap().as_str(),
    Some("first")
);
assert_eq!(
    value.get_path("items[1].name").unwrap().as_str(),
    Some("second")
);

pub fn query(&self, path: &str) -> Vec<&Value>

Query nested values using an extended path expression.

Returns all matching values. Supports:

  • Dot notation: "foo.bar.baz"
  • Bracket indexing: "items[0]"
  • Wildcard: "items[*]" or "items.*" — matches all children
  • Recursive descent: "..name" — finds name at any depth
§Examples
use noyalib::{from_str, Value};

let yaml = "items:\n  - name: a\n    v: 1\n  - name: b\n    v: 2\n";
let value: Value = from_str(yaml).unwrap();

// Wildcard: all items
let all = value.query("items[*].name");
assert_eq!(all.len(), 2);

// Recursive descent: find "name" at any depth
let names = value.query("..name");
assert_eq!(names.len(), 2);

pub fn get_path_mut(&mut self, path: &str) -> Option<&mut Value>

Mutably access a nested value using a path string.

See get_path for path syntax documentation.

§Examples
use noyalib::{from_str, Value};

let yaml = "server:\n  port: 8080\n";
let mut value: Value = from_str(yaml).unwrap();

if let Some(port) = value.get_path_mut("server.port") {
    *port = Value::from(9090);
}

assert_eq!(value.get_path("server.port").unwrap().as_i64(), Some(9090));

pub fn merge(&mut self, other: Value)

Deep merge another value into this one.

Merge behavior:

  • Mappings: keys from other are merged recursively; other keys override self keys
  • Sequences: other sequence replaces self sequence (use merge_concat for concatenation)
  • Scalars: other value replaces self value
  • Null in other: replaces self value
§Examples
use noyalib::{from_str, Value};

let mut base: Value = from_str(
    "
server:
  host: localhost
  port: 8080
",
)
.unwrap();

let override_val: Value = from_str(
    "
server:
  port: 9090
  ssl: true
",
)
.unwrap();

base.merge(override_val);

assert_eq!(
    base.get_path("server.host").unwrap().as_str(),
    Some("localhost")
);
assert_eq!(base.get_path("server.port").unwrap().as_i64(), Some(9090));
assert_eq!(base.get_path("server.ssl").unwrap().as_bool(), Some(true));

pub fn merge_concat(&mut self, other: Value)

Deep merge with sequence concatenation.

Similar to merge, but sequences are concatenated instead of replaced.

§Examples
use noyalib::{from_str, Value};

let mut base: Value = from_str("items:\n  - a\n  - b\n").unwrap();
let other: Value = from_str("items:\n  - c\n  - d\n").unwrap();

base.merge_concat(other);

let items = base.get("items").unwrap().as_sequence().unwrap();
assert_eq!(items.len(), 4);

pub fn remove(&mut self, key: &str) -> Option<Value>

Remove a key from a mapping.

Returns the removed value if the key existed and this is a mapping.

§Examples
use noyalib::{from_str, Value};

let mut value: Value = from_str("a: 1\nb: 2\n").unwrap();
let removed = value.remove("a");

assert_eq!(removed.unwrap().as_i64(), Some(1));
assert!(value.get("a").is_none());

pub fn insert(&mut self, key: impl Into<String>, value: Value) -> Option<Value>

Insert a key-value pair into a mapping.

Returns the previous value if the key existed. Returns None if this is not a mapping.

§Examples
use noyalib::{from_str, Value};

let mut value: Value = from_str("a: 1\n").unwrap();
value.insert("b", Value::from(2));

assert_eq!(value.get("b").unwrap().as_i64(), Some(2));

pub fn apply_merge(&mut self) -> Result<(), Error>

Performs merging of << keys into the surrounding mapping.

This implements YAML’s merge key functionality as described in https://yaml.org/type/merge.html.

The merge key << is used to indicate that all the keys of one or more specified mappings should be inserted into the current mapping. If a key already exists in the current mapping, its value is NOT overridden.

§Examples
use noyalib::{from_str, Value};

let config = r#"
defaults: &defaults
  timeout: 30
  retries: 3

server:
  <<: *defaults
  host: localhost
  timeout: 60
"#;

let mut value: Value = from_str(config).unwrap();
value.apply_merge().unwrap();

// The server mapping now has merged values from defaults
assert_eq!(value["server"]["host"].as_str(), Some("localhost"));
assert_eq!(value["server"]["timeout"].as_i64(), Some(60)); // Not overridden
assert_eq!(value["server"]["retries"].as_i64(), Some(3));  // Merged from defaults
§Multiple Merge Sources

When << is followed by a sequence of mappings, they are merged in order. Earlier mappings in the sequence take precedence for duplicate keys.

use noyalib::{from_str, Value};

let yaml = r#"
a: &a
  x: 1
b: &b
  x: 2
  y: 2
merged:
  <<: [*a, *b]
  z: 3
"#;

let mut value: Value = from_str(yaml).unwrap();
value.apply_merge().unwrap();

assert_eq!(value["merged"]["x"].as_i64(), Some(1)); // From *a (first)
assert_eq!(value["merged"]["y"].as_i64(), Some(2)); // From *b
assert_eq!(value["merged"]["z"].as_i64(), Some(3)); // Direct value
§Errors

Returns an error if:

  • A merge key value is a scalar (not a mapping or sequence of mappings)
  • A merge key value is a tagged value
  • A sequence in a merge key contains non-mapping values

pub fn interpolate_properties<S>( &mut self, properties: &HashMap<String, S>, ) -> Result<(), Error>
where S: AsRef<str>,

Substitute every ${name} reference inside string scalars with the corresponding entry from properties. The walk is recursive — strings nested inside sequences, mappings, and tagged values are all visited.

String keys in mappings are treated as opaque and never interpolated; only string values are touched. This avoids surprising key-rename interactions and keeps the schema stable.

${{ and }} escape sequences let users include literal ${ and } in a scalar that should not be interpreted as an interpolation site.

§Errors

Returns Error::Custom with the offending placeholder name when a ${name} reference is not present in properties. Use Value::interpolate_properties_lossy to substitute an empty string for unknown placeholders without erroring.

§Examples
use noyalib::{from_str, Value};
use std::collections::HashMap;

let mut value: Value = from_str("\
service:
  name: ${APP_NAME}
  port: ${BIND_PORT}
").unwrap();

let mut props = HashMap::new();
props.insert("APP_NAME".to_string(), "noyalib".to_string());
props.insert("BIND_PORT".to_string(), "8080".to_string());

value.interpolate_properties(&props).unwrap();
assert_eq!(value["service"]["name"].as_str(), Some("noyalib"));
// The numeric value stays as a string — re-deserialize the
// tree if you need typed coercion.
assert_eq!(value["service"]["port"].as_str(), Some("8080"));

pub fn interpolate_properties_redacted<S>( &mut self, properties: &HashMap<String, S>, ) -> Result<(), Error>
where S: AsRef<str>,

Like Value::interpolate_properties but redacts the placeholder name from any error surfaced when an unknown ${name} is encountered — useful when the placeholder name itself is sensitive (e.g. it carries an audit-trail secret identifier, or it’s used in a context where logs are externally indexed).

On success this method is identical to interpolate_properties. On failure the error reads interpolate_properties: unknown placeholder ${"<redacted>"} instead of including the original name. Substituted values (the contents of the property map) are never echoed to errors — that’s the responsibility of the caller’s downstream validators.

§Examples
use noyalib::{from_str, Value};
use std::collections::HashMap;

let mut value: Value = from_str("token: ${SECRET_TOKEN_NAME}").unwrap();
// Empty property map — substitution fails. With the
// redacting variant the placeholder name does not leak.
let props: HashMap<String, String> = HashMap::new();
let err = value.interpolate_properties_redacted(&props).unwrap_err();
let msg = err.to_string();
assert!(msg.contains("<redacted>"));
assert!(!msg.contains("SECRET_TOKEN_NAME"));

pub fn interpolate_properties_lossy<S>( &mut self, properties: &HashMap<String, S>, )
where S: AsRef<str>,

Like Value::interpolate_properties but never errors — unknown placeholders are replaced with an empty string. The motivating use case is environment-variable expansion where missing variables should silently degrade rather than abort the load.

§Examples
use noyalib::{from_str, Value};
use std::collections::HashMap;

let mut value: Value = from_str("greeting: hello ${WHO}, hello ${MISSING}").unwrap();
let mut props: HashMap<String, String> = HashMap::new();
props.insert("WHO".into(), "world".into());

value.interpolate_properties_lossy(&props);
assert_eq!(value["greeting"].as_str(), Some("hello world, hello "));

pub fn untag(self) -> Value

Recursively strips tags from this value, returning the untagged value.

If the value is Value::Tagged, the inner value is returned (recursively untagged). Sequences and mappings have their elements recursively untagged.

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("!Custom 'hi'\n").unwrap();
assert!(v.is_tagged());
let untagged = v.untag();
assert_eq!(untagged.as_str(), Some("hi"));

pub fn untag_ref(&self) -> &Value

Returns a reference to the innermost untagged value.

If the value is Value::Tagged, returns a reference to the inner value (recursively following tags). Does not recurse into sequences or mappings.

§Examples
use noyalib::{from_str, Value};
let v: Value = from_str("!Custom 'hi'\n").unwrap();
assert_eq!(v.untag_ref().as_str(), Some("hi"));

pub fn untag_mut(&mut self) -> &mut Value

Returns a mutable reference to the innermost untagged value.

If the value is Value::Tagged, returns a mutable reference to the inner value (recursively following tags). Does not recurse into sequences or mappings.

§Examples
use noyalib::{from_str, Value};
let mut v: Value = from_str("!Custom 'hi'\n").unwrap();
*v.untag_mut() = Value::from("bye");
assert_eq!(v.untag_ref().as_str(), Some("bye"));

Trait Implementations§

§

impl Clone for Value

§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
§

impl Debug for Value

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Value

§

fn default() -> Value

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for Value

§

fn deserialize<D>( deserializer: D, ) -> Result<Value, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<'de> Deserializer<'de> for &'de Value

§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
§

fn deserialize_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
§

fn deserialize_enum<V>( self, name: &'static str, variants: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
§

fn deserialize_seq<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
§

fn deserialize_map<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
§

fn deserialize_struct<V>( self, name: &'static str, _fields: &'static [&'static str], visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
§

fn deserialize_bool<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
§

fn deserialize_i8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
§

fn deserialize_i16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
§

fn deserialize_i32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
§

fn deserialize_i64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
§

fn deserialize_u8<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
§

fn deserialize_u16<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
§

fn deserialize_u32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
§

fn deserialize_u64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
§

fn deserialize_f32<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
§

fn deserialize_f64<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
§

fn deserialize_char<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
§

fn deserialize_str<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
§

fn deserialize_string<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
§

fn deserialize_option<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
§

fn deserialize_unit<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
§

fn deserialize_unit_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
§

fn deserialize_newtype_struct<V>( self, name: &'static str, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, <&'de Value as Deserializer<'de>>::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn deserialize_i128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u128<V>( self, visitor: V, ) -> Result<<V as Visitor<'de>>::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
§

impl Display for Value

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> From<&[T]> for Value
where T: Clone + Into<Value>,

§

fn from(v: &[T]) -> Value

Converts to this type from the input type.
§

impl From<&str> for Value

§

fn from(v: &str) -> Value

Converts to this type from the input type.
§

impl From<()> for Value

§

fn from(_: ()) -> Value

Converts to this type from the input type.
§

impl<'a> From<Cow<'a, str>> for Value

§

fn from(v: Cow<'a, str>) -> Value

Converts to this type from the input type.
§

impl From<Mapping> for Value

§

fn from(v: Mapping) -> Value

Converts to this type from the input type.
§

impl From<Number> for Value

§

fn from(v: Number) -> Value

Converts to this type from the input type.
§

impl<T> From<Option<T>> for Value
where T: Into<Value>,

§

fn from(v: Option<T>) -> Value

Converts to this type from the input type.
§

impl From<String> for Value

§

fn from(v: String) -> Value

Converts to this type from the input type.
§

impl From<TaggedValue> for Value

§

fn from(v: TaggedValue) -> Value

Converts to this type from the input type.
§

impl<T> From<Vec<T>> for Value
where T: Into<Value>,

§

fn from(v: Vec<T>) -> Value

Converts to this type from the input type.
§

impl From<bool> for Value

§

fn from(v: bool) -> Value

Converts to this type from the input type.
§

impl From<f32> for Value

§

fn from(v: f32) -> Value

Converts to this type from the input type.
§

impl From<f64> for Value

§

fn from(v: f64) -> Value

Converts to this type from the input type.
§

impl From<i16> for Value

§

fn from(v: i16) -> Value

Converts to this type from the input type.
§

impl From<i32> for Value

§

fn from(v: i32) -> Value

Converts to this type from the input type.
§

impl From<i64> for Value

§

fn from(v: i64) -> Value

Converts to this type from the input type.
§

impl From<i8> for Value

§

fn from(v: i8) -> Value

Converts to this type from the input type.
§

impl From<isize> for Value

§

fn from(v: isize) -> Value

Converts to this type from the input type.
§

impl From<u16> for Value

§

fn from(v: u16) -> Value

Converts to this type from the input type.
§

impl From<u32> for Value

§

fn from(v: u32) -> Value

Converts to this type from the input type.
§

impl From<u64> for Value

§

fn from(v: u64) -> Value

Converts to this type from the input type.
§

impl From<u8> for Value

§

fn from(v: u8) -> Value

Converts to this type from the input type.
§

impl From<usize> for Value

§

fn from(v: usize) -> Value

Converts to this type from the input type.
§

impl<T> FromIterator<T> for Value
where T: Into<Value>,

§

fn from_iter<I>(iter: I) -> Value
where I: IntoIterator<Item = T>,

Creates a value from an iterator. Read more
§

impl Hash for Value

§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

Feeds a slice of this type into the given Hasher. Read more
§

impl Index<&str> for Value

§

fn index(&self, key: &str) -> &<Value as Index<&str>>::Output

Index into a YAML mapping by key.

§Panics

Panics if the value is not a mapping or if the key is not found.

§Examples
use noyalib::{from_str, Value};

let yaml = "name: test\nversion: 1\n";
let value: Value = from_str(yaml).unwrap();
assert_eq!(value["name"].as_str(), Some("test"));
assert_eq!(value["version"].as_i64(), Some(1));
§

type Output = Value

The returned type after indexing.
§

impl Index<usize> for Value

§

fn index(&self, index: usize) -> &<Value as Index<usize>>::Output

Index into a YAML sequence.

§Panics

Panics if the value is not a sequence or if the index is out of bounds.

§Examples
use noyalib::{from_str, Value};

let yaml = "- a\n- b\n- c\n";
let value: Value = from_str(yaml).unwrap();
assert_eq!(value[0].as_str(), Some("a"));
assert_eq!(value[1].as_str(), Some("b"));
§

type Output = Value

The returned type after indexing.
§

impl IndexMut<&str> for Value

§

fn index_mut(&mut self, key: &str) -> &mut <Value as Index<&str>>::Output

Mutably index into a YAML mapping by key.

§Panics

Panics if the value is not a mapping or if the key is not found.

§

impl IndexMut<usize> for Value

§

fn index_mut(&mut self, index: usize) -> &mut <Value as Index<usize>>::Output

Mutably index into a YAML sequence.

§Panics

Panics if the value is not a sequence or if the index is out of bounds.

§

impl<'de> IntoDeserializer<'de, Error> for &'de Value

§

type Deserializer = &'de Value

The type of the deserializer being converted into.
§

fn into_deserializer( self, ) -> <&'de Value as IntoDeserializer<'de, Error>>::Deserializer

Convert this value into a deserializer.
§

impl Ord for Value

§

fn cmp(&self, other: &Value) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
§

impl PartialEq for Value

§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for Value

§

fn partial_cmp(&self, other: &Value) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl Serialize for Value

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl ValueIndex for &Value

§

fn index_into(self, value: &Value) -> Option<&Value>

Index into a value, returning a reference to the element if found. Read more
§

fn index_into_mut(self, value: &mut Value) -> Option<&mut Value>

Mutably index into a value, returning a mutable reference to the element if found. Read more
§

fn index_or_insert(self, value: &mut Value) -> &mut Value

Index into a value, inserting a default value if the key doesn’t exist. Read more
§

impl Eq for Value

Auto Trait Implementations§

§

impl Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnsafeUnpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,