Skip to main content

Value

Enum Value 

Source
pub enum Value {
    Null,
    Bool(bool),
    Number(Number),
    String(String),
    Sequence(Sequence),
    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(Sequence)

Represents a YAML sequence (array).

§

Mapping(Mapping)

Represents a YAML mapping (object).

§

Tagged(Box<TaggedValue>)

Represents a tagged YAML value.

Implementations§

Source§

impl Value

Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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());
Source

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);
Source

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);
Source

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);
Source

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);
Source

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);
Source

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());
Source

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());
Source

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());
Source

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);
Source

pub fn as_sequence(&self) -> Option<&Sequence>

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));
Source

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

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);
Source

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));
Source

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);
Source

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");
Source

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"));
Source

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

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));
Source

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

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));
Source

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")
);
Source

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);
Source

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));
Source

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));
Source

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);
Source

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());
Source

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));
Source

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

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
Source

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

Available on crate feature std only.

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"));
Source

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

Available on crate feature std only.

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"));
Source

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

Available on crate feature std only.

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 "));
Source

pub fn untag(self) -> Self

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"));
Source

pub fn untag_ref(&self) -> &Self

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"));
Source

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

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§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Value

Source§

fn default() -> Value

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

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

Source§

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

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

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

Source§

type Error = Error

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

fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>
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
Source§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

fn deserialize_str<V>( self, visitor: V, ) -> Result<V::Value, <Self 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
Source§

fn deserialize_string<V>( self, visitor: V, ) -> Result<V::Value, <Self 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
Source§

fn deserialize_bytes<V>( self, visitor: V, ) -> Result<V::Value, <Self 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
Source§

fn deserialize_byte_buf<V>( self, visitor: V, ) -> Result<V::Value, <Self 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
Source§

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

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

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

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

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

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

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

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

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<V::Value, <Self 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.
Source§

fn deserialize_tuple_struct<V>( self, name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, <Self 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.
Source§

fn deserialize_identifier<V>( self, visitor: V, ) -> Result<V::Value, <Self 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.
Source§

fn deserialize_ignored_any<V>( self, visitor: V, ) -> Result<V::Value, <Self 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
Source§

impl Display for Value

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(v: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for Value

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<Mapping> for Value

Source§

fn from(v: Mapping) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Value

Source§

fn from(v: Number) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(v: String) -> Self

Converts to this type from the input type.
Source§

impl From<TaggedValue> for Value

Source§

fn from(v: TaggedValue) -> Self

Converts to this type from the input type.
Source§

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

Source§

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

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(v: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(v: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(v: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(v: i8) -> Self

Converts to this type from the input type.
Source§

impl From<isize> for Value

Source§

fn from(v: isize) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(v: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(v: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Value

Source§

fn from(v: usize) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Value

Source§

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

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
Source§

impl Index<&Value> for MappingAny

Source§

fn index(&self, key: &Value) -> &Self::Output

Index into the mapping by key.

§Panics

Panics if the key is not present in the mapping.

Source§

type Output = Value

The returned type after indexing.
Source§

impl Index<&str> for Value

Source§

fn index(&self, key: &str) -> &Self::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));
Source§

type Output = Value

The returned type after indexing.
Source§

impl Index<usize> for Value

Source§

fn index(&self, index: usize) -> &Self::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"));
Source§

type Output = Value

The returned type after indexing.
Source§

impl IndexMut<&Value> for MappingAny

Source§

fn index_mut(&mut self, key: &Value) -> &mut Self::Output

Mutably index into the mapping by key.

§Panics

Panics if the key is not present in the mapping.

Source§

impl IndexMut<&str> for Value

Source§

fn index_mut(&mut self, key: &str) -> &mut Self::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.

Source§

impl IndexMut<usize> for Value

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Mutably index into a YAML sequence.

§Panics

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

Source§

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

Source§

type Deserializer = &'de Value

The type of the deserializer being converted into.
Source§

fn into_deserializer(self) -> Self::Deserializer

Convert this value into a deserializer.
Source§

impl JsonSchema for Value

Available on crate feature schema only.

JsonSchema for crate::Value — the dynamic value tree admits any JSON-expressible shape, so the schema we emit is the JSON Schema 2020-12 idiom for “any value”: {"oneOf": [...]} enumerating null, boolean, number, string, array, and object. Object values use a recursive additionalProperties reference so deeply-nested Value payloads typecheck without a depth bound.

This impl lets users derive JsonSchema on a struct that has a noyalib::Value field — e.g. when the field’s type is “any user-supplied YAML scalar / mapping / sequence” and the caller still wants a published schema for the surrounding shape.

§Examples

use noyalib::{schema_for, JsonSchema, Value};
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, JsonSchema)]
struct Envelope {
    id: String,
    payload: Value,
}

let schema = schema_for::<Envelope>().unwrap();
// The `payload` field is described by the `Value` schema —
// a oneOf union covering every JSON-expressible shape.
assert_eq!(schema["type"].as_str(), Some("object"));
assert!(matches!(schema["properties"]["payload"], Value::Mapping(_)));
Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(_generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl Ord for Value

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

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

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Value

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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.
Source§

impl PartialOrd for Value

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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 (const: unstable) · 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
Source§

impl Serialize for Value

Source§

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

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

impl Value for Value

Available on crate feature sval only.
Source§

fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S, ) -> Result

Stream this value through a Stream.
Source§

fn tag(&self) -> Option<Tag>

Get the tag of this value, if there is one.
Source§

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

Try convert this value into a boolean.
Source§

fn to_f32(&self) -> Option<f32>

Try convert this value into a 32bit binary floating point number.
Source§

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

Try convert this value into a 64bit binary floating point number.
Source§

fn to_i8(&self) -> Option<i8>

Try convert this value into a signed 8bit integer.
Source§

fn to_i16(&self) -> Option<i16>

Try convert this value into a signed 16bit integer.
Source§

fn to_i32(&self) -> Option<i32>

Try convert this value into a signed 32bit integer.
Source§

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

Try convert this value into a signed 64bit integer.
Source§

fn to_i128(&self) -> Option<i128>

Try convert this value into a signed 128bit integer.
Source§

fn to_u8(&self) -> Option<u8>

Try convert this value into an unsigned 8bit integer.
Source§

fn to_u16(&self) -> Option<u16>

Try convert this value into an unsigned 16bit integer.
Source§

fn to_u32(&self) -> Option<u32>

Try convert this value into an unsigned 32bit integer.
Source§

fn to_u64(&self) -> Option<u64>

Try convert this value into an unsigned 64bit integer.
Source§

fn to_u128(&self) -> Option<u128>

Try convert this value into an unsigned 128bit integer.
Source§

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

Try convert this value into a text string.
Source§

fn to_binary(&self) -> Option<&[u8]>

Try convert this value into a bitstring.
Source§

impl ValueIndex for &Value

Source§

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

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

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
Source§

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
Source§

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
Source§

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

Source§

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

Compare self to key and return their ordering.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

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

Source§

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

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

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

Source§

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

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

impl<T> Fmt for T
where T: Display,

Source§

fn fg<C>(self, color: C) -> Foreground<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified foreground colour.
Source§

fn bg<C>(self, color: C) -> Background<Self>
where C: Into<Option<Color>>, Self: Display,

Give this value the specified background colour.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, O> Matches<O> for T
where T: PartialEq<O>,

Source§

fn validate_matches(&self, other: &O) -> bool

Source§

impl<D> OwoColorize for D

Source§

fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>
where C: Color,

Set the foreground color generically Read more
Source§

fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>
where C: Color,

Set the background color generically. Read more
Source§

fn black(&self) -> FgColorDisplay<'_, Black, Self>

Change the foreground color to black
Source§

fn on_black(&self) -> BgColorDisplay<'_, Black, Self>

Change the background color to black
Source§

fn red(&self) -> FgColorDisplay<'_, Red, Self>

Change the foreground color to red
Source§

fn on_red(&self) -> BgColorDisplay<'_, Red, Self>

Change the background color to red
Source§

fn green(&self) -> FgColorDisplay<'_, Green, Self>

Change the foreground color to green
Source§

fn on_green(&self) -> BgColorDisplay<'_, Green, Self>

Change the background color to green
Source§

fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>

Change the foreground color to yellow
Source§

fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>

Change the background color to yellow
Source§

fn blue(&self) -> FgColorDisplay<'_, Blue, Self>

Change the foreground color to blue
Source§

fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>

Change the background color to blue
Source§

fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to magenta
Source§

fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to magenta
Source§

fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>

Change the foreground color to purple
Source§

fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>

Change the background color to purple
Source§

fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>

Change the foreground color to cyan
Source§

fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>

Change the background color to cyan
Source§

fn white(&self) -> FgColorDisplay<'_, White, Self>

Change the foreground color to white
Source§

fn on_white(&self) -> BgColorDisplay<'_, White, Self>

Change the background color to white
Source§

fn default_color(&self) -> FgColorDisplay<'_, Default, Self>

Change the foreground color to the terminal default
Source§

fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>

Change the background color to the terminal default
Source§

fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>

Change the foreground color to bright black
Source§

fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>

Change the background color to bright black
Source§

fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>

Change the foreground color to bright red
Source§

fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>

Change the background color to bright red
Source§

fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>

Change the foreground color to bright green
Source§

fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>

Change the background color to bright green
Source§

fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>

Change the foreground color to bright yellow
Source§

fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>

Change the background color to bright yellow
Source§

fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>

Change the foreground color to bright blue
Source§

fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>

Change the background color to bright blue
Source§

fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright magenta
Source§

fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright magenta
Source§

fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>

Change the foreground color to bright purple
Source§

fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>

Change the background color to bright purple
Source§

fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>

Change the foreground color to bright cyan
Source§

fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>

Change the background color to bright cyan
Source§

fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>

Change the foreground color to bright white
Source§

fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>

Change the background color to bright white
Source§

fn bold(&self) -> BoldDisplay<'_, Self>

Make the text bold
Source§

fn dimmed(&self) -> DimDisplay<'_, Self>

Make the text dim
Source§

fn italic(&self) -> ItalicDisplay<'_, Self>

Make the text italicized
Source§

fn underline(&self) -> UnderlineDisplay<'_, Self>

Make the text underlined
Make the text blink
Make the text blink (but fast!)
Source§

fn reversed(&self) -> ReversedDisplay<'_, Self>

Swap the foreground and background colors
Source§

fn hidden(&self) -> HiddenDisplay<'_, Self>

Hide the text
Source§

fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>

Cross out the text
Source§

fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the foreground color at runtime. Only use if you do not know which color will be used at compile-time. If the color is constant, use either OwoColorize::fg or a color-specific method, such as OwoColorize::green, Read more
Source§

fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>
where Color: DynColor,

Set the background color at runtime. Only use if you do not know what color to use at compile-time. If the color is constant, use either OwoColorize::bg or a color-specific method, such as OwoColorize::on_yellow, Read more
Source§

fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the foreground color to a specific RGB value.
Source§

fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>

Set the background color to a specific RGB value.
Source§

fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>

Sets the foreground color to an RGB value.
Source§

fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>

Sets the background color to an RGB value.
Source§

fn style(&self, style: Style) -> Styled<&Self>

Apply a runtime-determined style
Source§

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

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToCompactString for T
where T: Display,

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> ValidateIp for T
where T: ToString,

Source§

fn validate_ipv4(&self) -> bool

Validates whether the given string is an IP V4
Source§

fn validate_ipv6(&self) -> bool

Validates whether the given string is an IP V6
Source§

fn validate_ip(&self) -> bool

Validates whether the given string is an IP
Source§

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

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T