pub struct Mapping(/* private fields */);Expand description
A YAML mapping (dictionary/object).
This is an ordered map that preserves insertion order, wrapping
IndexMap<String, Value>. It provides a comprehensive API for working with
YAML mappings.
§Examples
use noyalib::{Mapping, Value};
let mut map = Mapping::new();
map.insert("name", Value::from("test"));
map.insert("value", Value::from(42));
assert_eq!(map.len(), 2);
assert_eq!(map.get("name").unwrap().as_str(), Some("test"));Implementations§
Source§impl Mapping
impl Mapping
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty mapping.
§Examples
use noyalib::Mapping;
let m = Mapping::new();
assert!(m.is_empty());Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty mapping with the specified capacity.
Pre-allocates room for capacity entries to avoid
rehashing during the first inserts.
§Examples
use noyalib::Mapping;
let m = Mapping::with_capacity(16);
assert!(m.capacity() >= 16);Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of key-value pairs the mapping can hold without reallocating.
§Examples
use noyalib::Mapping;
let m = Mapping::with_capacity(8);
assert!(m.capacity() >= 8);Sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional more key-value pairs.
§Examples
use noyalib::Mapping;
let mut m = Mapping::new();
m.reserve(64);
assert!(m.capacity() >= 64);Sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrinks the capacity of the mapping as much as possible.
§Examples
use noyalib::Mapping;
let mut m = Mapping::with_capacity(64);
m.shrink_to_fit();
// capacity may now be 0 or any small implementation-defined value.Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of key-value pairs in the mapping.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
assert_eq!(m.len(), 1);Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the mapping contains no key-value pairs.
§Examples
use noyalib::Mapping;
assert!(Mapping::new().is_empty());Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears the mapping, removing all key-value pairs.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.clear();
assert!(m.is_empty());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>
Inserts a key-value pair into the mapping.
If the mapping already had this key present, the value is updated, and the old value is returned.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
assert_eq!(m.insert("a", Value::from(1_i64)), None);
assert_eq!(m.insert("a", Value::from(2_i64)).and_then(|v| v.as_i64()), Some(1));Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Returns true if the mapping contains the specified key.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
assert!(m.contains_key("a"));
assert!(!m.contains_key("b"));Sourcepub fn get(&self, key: &str) -> Option<&Value>
pub fn get(&self, key: &str) -> Option<&Value>
Returns a reference to the value corresponding to the key.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
assert_eq!(m.get("a").and_then(Value::as_i64), Some(1));
assert!(m.get("b").is_none());Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Returns a mutable reference to the value corresponding to the key.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
if let Some(v) = m.get_mut("a") {
*v = Value::from(2_i64);
}
assert_eq!(m.get("a").and_then(Value::as_i64), Some(2));Sourcepub fn get_index(&self, index: usize) -> Option<(&String, &Value)>
pub fn get_index(&self, index: usize) -> Option<(&String, &Value)>
Returns a reference to the key-value pair at the given index.
Indexing follows insertion order (this is an IndexMap).
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("first", Value::from(1_i64));
m.insert("second", Value::from(2_i64));
assert_eq!(m.get_index(0).map(|(k, _)| k.as_str()), Some("first"));Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<(&String, &mut Value)>
pub fn get_index_mut(&mut self, index: usize) -> Option<(&String, &mut Value)>
Returns a mutable reference to the key-value pair at the given index.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
if let Some((_, v)) = m.get_index_mut(0) {
*v = Value::from(99_i64);
}
assert_eq!(m.get("a").and_then(Value::as_i64), Some(99));Sourcepub fn remove(&mut self, key: &str) -> Option<Value>
pub fn remove(&mut self, key: &str) -> Option<Value>
Removes a key from the mapping, returning the value if the key was present.
This operation preserves the order of remaining elements
(uses shift_remove semantics, O(n)). For order-agnostic
O(1) removal, see Mapping::swap_remove.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
assert_eq!(m.remove("a").and_then(|v| v.as_i64()), Some(1));
assert!(m.remove("a").is_none());Sourcepub fn remove_entry(&mut self, key: &str) -> Option<(String, Value)>
pub fn remove_entry(&mut self, key: &str) -> Option<(String, Value)>
Removes a key from the mapping, returning the key-value pair if present.
This operation preserves the order of remaining elements.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
let (k, v) = m.remove_entry("a").unwrap();
assert_eq!(k, "a");
assert_eq!(v.as_i64(), Some(1));Sourcepub fn swap_remove(&mut self, key: &str) -> Option<Value>
pub fn swap_remove(&mut self, key: &str) -> Option<Value>
Removes a key by swapping it with the last element.
This is O(1) but does not preserve order. For
order-preserving removal, see Mapping::remove or
Mapping::shift_remove.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
m.insert("c", Value::from(3_i64));
m.swap_remove("a");
// Order is no longer guaranteed; "c" might now sit where "a" was.
assert_eq!(m.len(), 2);Sourcepub fn shift_remove(&mut self, key: &str) -> Option<Value>
pub fn shift_remove(&mut self, key: &str) -> Option<Value>
Removes a key by shifting all elements after it.
This preserves order but is O(n). Equivalent to
Mapping::remove.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
m.shift_remove("a");
assert_eq!(m.iter().next().map(|(k, _)| k.as_str()), Some("b"));Sourcepub fn entry(&mut self, key: impl Into<String>) -> Entry<'_, String, Value>
pub fn entry(&mut self, key: impl Into<String>) -> Entry<'_, String, Value>
Gets the entry for the given key for in-place manipulation.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.entry("counter").or_insert(Value::from(0_i64));
if let Some(Value::Number(n)) = m.get_mut("counter") {
if let Some(c) = n.as_i64() { *n = noyalib::Number::Integer(c + 1); }
}
assert_eq!(m.get("counter").and_then(Value::as_i64), Some(1));Sourcepub fn retain<F>(&mut self, f: F)
pub fn retain<F>(&mut self, f: F)
Retains only the key-value pairs specified by the predicate.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
m.insert("c", Value::from(3_i64));
m.retain(|_k, v| v.as_i64().unwrap_or(0) >= 2);
assert_eq!(m.len(), 2);
assert!(!m.contains_key("a"));Sourcepub fn iter(&self) -> Iter<'_, String, Value>
pub fn iter(&self) -> Iter<'_, String, Value>
Returns an iterator over the key-value pairs in insertion order.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
let total: i64 = m.iter().filter_map(|(_, v)| v.as_i64()).sum();
assert_eq!(total, 3);Sourcepub fn iter_mut(&mut self) -> IterMut<'_, String, Value>
pub fn iter_mut(&mut self) -> IterMut<'_, String, Value>
Returns a mutable iterator over the key-value pairs in insertion order.
§Examples
use noyalib::{Mapping, Number, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
for (_, v) in m.iter_mut() {
if let Value::Number(Number::Integer(n)) = v { *n *= 2; }
}
assert_eq!(m.get("a").and_then(Value::as_i64), Some(2));Sourcepub fn keys(&self) -> Keys<'_, String, Value>
pub fn keys(&self) -> Keys<'_, String, Value>
Returns an iterator over the keys in insertion order.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
let keys: Vec<&str> = m.keys().map(String::as_str).collect();
assert_eq!(keys, &["a", "b"]);Sourcepub fn values(&self) -> Values<'_, String, Value>
pub fn values(&self) -> Values<'_, String, Value>
Returns an iterator over the values in insertion order.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
let sum: i64 = m.values().filter_map(Value::as_i64).sum();
assert_eq!(sum, 3);Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, String, Value>
pub fn values_mut(&mut self) -> ValuesMut<'_, String, Value>
Returns a mutable iterator over the values in insertion order.
§Examples
use noyalib::{Mapping, Number, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(10_i64));
m.insert("b", Value::from(20_i64));
for v in m.values_mut() {
if let Value::Number(Number::Integer(n)) = v { *n /= 10; }
}
assert_eq!(m.get("a").and_then(Value::as_i64), Some(1));Sourcepub fn first(&self) -> Option<(&String, &Value)>
pub fn first(&self) -> Option<(&String, &Value)>
Returns the first key-value pair in insertion order.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
assert_eq!(m.first().map(|(k, _)| k.as_str()), Some("a"));Sourcepub fn first_mut(&mut self) -> Option<(&String, &mut Value)>
pub fn first_mut(&mut self) -> Option<(&String, &mut Value)>
Returns a mutable reference to the first key-value pair.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
if let Some((_, v)) = m.first_mut() { *v = Value::from(99_i64); }
assert_eq!(m.get("a").and_then(Value::as_i64), Some(99));Sourcepub fn last(&self) -> Option<(&String, &Value)>
pub fn last(&self) -> Option<(&String, &Value)>
Returns the last key-value pair in insertion order.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
assert_eq!(m.last().map(|(k, _)| k.as_str()), Some("b"));Sourcepub fn last_mut(&mut self) -> Option<(&String, &mut Value)>
pub fn last_mut(&mut self) -> Option<(&String, &mut Value)>
Returns a mutable reference to the last key-value pair.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
if let Some((_, v)) = m.last_mut() { *v = Value::from(99_i64); }
assert_eq!(m.get("b").and_then(Value::as_i64), Some(99));Sourcepub fn pop_first(&mut self) -> Option<(String, Value)>
pub fn pop_first(&mut self) -> Option<(String, Value)>
Removes and returns the first key-value pair.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
let (k, _) = m.pop_first().unwrap();
assert_eq!(k, "a");
assert_eq!(m.len(), 1);Sourcepub fn pop_last(&mut self) -> Option<(String, Value)>
pub fn pop_last(&mut self) -> Option<(String, Value)>
Removes and returns the last key-value pair.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
let (k, _) = m.pop_last().unwrap();
assert_eq!(k, "b");Sourcepub fn sort_keys(&mut self)
pub fn sort_keys(&mut self)
Sorts the mapping by keys (lexicographic order).
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("c", Value::from(3_i64));
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
m.sort_keys();
let keys: Vec<&str> = m.keys().map(String::as_str).collect();
assert_eq!(keys, &["a", "b", "c"]);Sourcepub fn reverse(&mut self)
pub fn reverse(&mut self)
Reverses the order of key-value pairs.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
m.insert("b", Value::from(2_i64));
m.reverse();
assert_eq!(m.first().map(|(k, _)| k.as_str()), Some("b"));Sourcepub fn extend<I>(&mut self, iter: I)
pub fn extend<I>(&mut self, iter: I)
Extends the mapping with the contents of an iterator.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.extend([
("a".to_owned(), Value::from(1_i64)),
("b".to_owned(), Value::from(2_i64)),
]);
assert_eq!(m.len(), 2);Sourcepub fn into_inner(self) -> IndexMap<String, Value>
pub fn into_inner(self) -> IndexMap<String, Value>
Consumes the mapping and returns its contents as an IndexMap.
§Examples
use noyalib::{Mapping, Value};
let mut m = Mapping::new();
m.insert("a", Value::from(1_i64));
let inner = m.into_inner();
assert_eq!(inner.len(), 1);Sourcepub fn from_inner(map: IndexMap<String, Value>) -> Self
pub fn from_inner(map: IndexMap<String, Value>) -> Self
Creates a mapping from an IndexMap.
§Examples
use indexmap::IndexMap;
use noyalib::{Mapping, Value};
let mut src = IndexMap::new();
src.insert("a".to_owned(), Value::from(1_i64));
let m = Mapping::from_inner(src);
assert_eq!(m.get("a").and_then(Value::as_i64), Some(1));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Mapping
impl<'de> Deserialize<'de> for Mapping
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>,
impl Eq for Mapping
Source§impl From<Mapping> for MappingAny
impl From<Mapping> for MappingAny
Source§impl IntoIterator for Mapping
impl IntoIterator for Mapping
Source§impl<'a> IntoIterator for &'a Mapping
impl<'a> IntoIterator for &'a Mapping
Source§impl<'a> IntoIterator for &'a mut Mapping
impl<'a> IntoIterator for &'a mut Mapping
Source§impl Ord for Mapping
impl Ord for Mapping
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 Mapping
impl PartialOrd for Mapping
impl StructuralPartialEq for Mapping
Source§impl Value for Mapping
Available on crate feature sval only.
impl Value for Mapping
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>
Auto Trait Implementations§
impl Freeze for Mapping
impl RefUnwindSafe for Mapping
impl Send for Mapping
impl Sync for Mapping
impl Unpin for Mapping
impl UnsafeUnpin for Mapping
impl UnwindSafe for Mapping
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
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.impl<T> ErasedDestructor for Twhere
T: 'static,
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
impl<T> MaybeSendSync for T
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