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
impl Value
Sourcepub fn is_null(&self) -> bool
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());Sourcepub fn is_bool(&self) -> bool
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());Sourcepub fn is_number(&self) -> 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());Sourcepub fn is_string(&self) -> bool
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());Sourcepub fn is_sequence(&self) -> bool
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());Sourcepub fn is_mapping(&self) -> bool
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());Sourcepub fn is_tagged(&self) -> bool
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());Sourcepub fn as_bool(&self) -> Option<bool>
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);Sourcepub fn as_null(&self) -> Option<()>
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);Sourcepub fn as_i64(&self) -> Option<i64>
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);Sourcepub fn as_u64(&self) -> Option<u64>
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);Sourcepub fn as_f64(&self) -> Option<f64>
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);Sourcepub fn is_i64(&self) -> bool
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());Sourcepub fn is_u64(&self) -> bool
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());Sourcepub fn is_f64(&self) -> bool
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());Sourcepub fn as_str(&self) -> Option<&str>
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);Sourcepub fn as_sequence(&self) -> Option<&Sequence>
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));Sourcepub fn as_sequence_mut(&mut self) -> Option<&mut Sequence>
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);Sourcepub fn as_mapping(&self) -> Option<&Mapping>
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));Sourcepub fn as_mapping_mut(&mut self) -> Option<&mut Mapping>
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);Sourcepub fn as_tagged(&self) -> Option<&TaggedValue>
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");Sourcepub fn as_tagged_mut(&mut self) -> Option<&mut TaggedValue>
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"));Sourcepub fn get<I: ValueIndex>(&self, index: I) -> Option<&Value>
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));Sourcepub fn get_mut<I: ValueIndex>(&mut self, index: I) -> Option<&mut Value>
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));Sourcepub fn get_path(&self, path: &str) -> Option<&Value>
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")
);Sourcepub fn query(&self, path: &str) -> Vec<&Value>
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"— findsnameat 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);Sourcepub fn get_path_mut(&mut self, path: &str) -> Option<&mut Value>
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));Sourcepub fn merge(&mut self, other: Value)
pub fn merge(&mut self, other: Value)
Deep merge another value into this one.
Merge behavior:
- Mappings: keys from
otherare merged recursively;otherkeys overrideselfkeys - Sequences:
othersequence replacesselfsequence (usemerge_concatfor concatenation) - Scalars:
othervalue replacesselfvalue - Null in
other: replacesselfvalue
§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));Sourcepub fn merge_concat(&mut self, other: Value)
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);Sourcepub fn remove(&mut self, key: &str) -> Option<Value>
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());Sourcepub fn insert(&mut self, key: impl Into<String>, value: Value) -> Option<Value>
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));Sourcepub fn apply_merge(&mut self) -> Result<()>
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
Sourcepub fn interpolate_properties<S>(
&mut self,
properties: &HashMap<String, S>,
) -> Result<()>
Available on crate feature std only.
pub fn interpolate_properties<S>( &mut self, properties: &HashMap<String, S>, ) -> Result<()>
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"));Sourcepub fn interpolate_properties_redacted<S>(
&mut self,
properties: &HashMap<String, S>,
) -> Result<()>
Available on crate feature std only.
pub fn interpolate_properties_redacted<S>( &mut self, properties: &HashMap<String, S>, ) -> Result<()>
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"));Sourcepub fn interpolate_properties_lossy<S>(
&mut self,
properties: &HashMap<String, S>,
)
Available on crate feature std only.
pub fn interpolate_properties_lossy<S>( &mut self, properties: &HashMap<String, S>, )
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 "));Sourcepub fn untag(self) -> Self
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"));Sourcepub fn untag_ref(&self) -> &Self
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"));Sourcepub fn untag_mut(&mut self) -> &mut Self
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<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'de> Deserializer<'de> for &'de Value
impl<'de> Deserializer<'de> for &'de Value
Source§type Error = Error
type Error = Error
Source§fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>where
V: Visitor<'de>,
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value>where
V: Visitor<'de>,
Deserializer to figure out how to drive the visitor based
on what data type is in the input. Read moreSource§fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value>where
V: Visitor<'de>,
fn deserialize_enum<V>(
self,
name: &'static str,
variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value>where
V: Visitor<'de>,
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>,
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value>where
V: Visitor<'de>,
Deserialize type is expecting a sequence of values.Source§fn deserialize_map<V>(self, visitor: V) -> Result<V::Value>where
V: Visitor<'de>,
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value>where
V: Visitor<'de>,
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>,
fn deserialize_struct<V>(
self,
name: &'static str,
_fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value>where
V: Visitor<'de>,
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>,
fn deserialize_bool<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_i8<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_i16<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_i32<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_i64<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_u8<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_u16<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_u32<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_u64<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_f32<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_f64<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_char<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_str<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_string<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
fn deserialize_string<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_bytes<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
fn deserialize_bytes<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_byte_buf<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
fn deserialize_byte_buf<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_option<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
fn deserialize_option<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type is expecting an optional value. Read moreSource§fn deserialize_unit<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
fn deserialize_unit<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_unit_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_newtype_struct<V>(
self,
name: &'static str,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_tuple<V>(
self,
len: usize,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
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>,
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>,
fn deserialize_identifier<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
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>,
fn deserialize_ignored_any<V>(
self,
visitor: V,
) -> Result<V::Value, <Self as Deserializer<'de>>::Error>where
V: Visitor<'de>,
Deserialize type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read moreSource§fn deserialize_i128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_u128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u128<V>(
self,
visitor: V,
) -> Result<<V as Visitor<'de>>::Value, Self::Error>where
V: Visitor<'de>,
Source§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Deserialize implementations should expect to
deserialize their human-readable form. Read moreSource§impl From<TaggedValue> for Value
impl From<TaggedValue> for Value
Source§fn from(v: TaggedValue) -> Self
fn from(v: TaggedValue) -> Self
Source§impl<T: Into<Value>> FromIterator<T> for Value
impl<T: Into<Value>> FromIterator<T> for Value
Source§fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self
Source§impl Index<&Value> for MappingAny
impl Index<&Value> for MappingAny
Source§impl Index<&str> for Value
impl Index<&str> for Value
Source§fn index(&self, key: &str) -> &Self::Output
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§impl Index<usize> for Value
impl Index<usize> for Value
Source§fn index(&self, index: usize) -> &Self::Output
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§impl IndexMut<&Value> for MappingAny
impl IndexMut<&Value> for MappingAny
Source§impl<'de> IntoDeserializer<'de, Error> for &'de Value
impl<'de> IntoDeserializer<'de, Error> for &'de Value
Source§type Deserializer = &'de Value
type Deserializer = &'de Value
Source§fn into_deserializer(self) -> Self::Deserializer
fn into_deserializer(self) -> Self::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.
impl JsonSchema for Value
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_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(_generator: &mut SchemaGenerator) -> Schema
fn json_schema(_generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl Ord for Value
impl Ord for Value
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Value
impl PartialOrd for Value
Source§impl Value for Value
Available on crate feature sval only.
impl Value for Value
sval only.Source§fn stream<'sval, S: Stream<'sval> + ?Sized>(
&'sval self,
stream: &mut S,
) -> Result
fn stream<'sval, S: Stream<'sval> + ?Sized>( &'sval self, stream: &mut S, ) -> Result
Stream.Source§fn to_f32(&self) -> Option<f32>
fn to_f32(&self) -> Option<f32>
Source§impl ValueIndex for &Value
impl ValueIndex for &Value
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T, O> Matches<O> for Twhere
T: PartialEq<O>,
impl<T, O> Matches<O> for Twhere
T: PartialEq<O>,
fn validate_matches(&self, other: &O) -> bool
Source§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read moreSource§fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self,
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>( &self, ) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
Source§fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
Source§fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
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 bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
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>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
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 rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
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 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.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more