ConcreteVariantObject

Trait ConcreteVariantObject 

Source
pub trait ConcreteVariantObject {
    type Value: VariantValue<VariantObject = Self>;

    // Required methods
    fn is_empty(&self) -> bool;
    fn len(&self) -> usize;
    fn get(&self, key: &str) -> Option<&Self::Value>;
    fn get_key_value(&self, key: &str) -> Option<(&String, &Self::Value)>;
    fn iter(&self) -> impl Iterator<Item = (&String, &Self::Value)>;
    fn values(&self) -> impl Iterator<Item = &Self::Value>;
}
Expand description

A trait for the concrete variant object type associated with a variant value.

Required Associated Types§

Source

type Value: VariantValue<VariantObject = Self>

The type of the value in the object.

Required Methods§

Source

fn is_empty(&self) -> bool

Whether the object is empty.

Source

fn len(&self) -> usize

The length of the object, i.e., the number of key-value pairs.

Source

fn get(&self, key: &str) -> Option<&Self::Value>

Get the value for the given key; None if the key is not present.

Source

fn get_key_value(&self, key: &str) -> Option<(&String, &Self::Value)>

Get the key-value pair for the given key; None if the key is not present.

Source

fn iter(&self) -> impl Iterator<Item = (&String, &Self::Value)>

An iterator over the key-value pairs in the object.

Source

fn values(&self) -> impl Iterator<Item = &Self::Value>

An iterator over the values in the object.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ConcreteVariantObject for Map<String, Value>

Available on crate feature json only.
Source§

type Value = Value

Source§

fn is_empty(&self) -> bool

Source§

fn len(&self) -> usize

Source§

fn get(&self, key: &str) -> Option<&Self::Value>

Source§

fn get_key_value(&self, key: &str) -> Option<(&String, &Self::Value)>

Source§

fn iter(&self) -> impl Iterator<Item = (&String, &Self::Value)>

Source§

fn values(&self) -> impl Iterator<Item = &Self::Value>

Source§

impl ConcreteVariantObject for Table

Available on crate feature toml only.
Source§

type Value = Value

Source§

fn is_empty(&self) -> bool

Source§

fn len(&self) -> usize

Source§

fn get(&self, key: &str) -> Option<&Self::Value>

Source§

fn get_key_value(&self, key: &str) -> Option<(&String, &Self::Value)>

Source§

fn iter(&self) -> impl Iterator<Item = (&String, &Self::Value)>

Source§

fn values(&self) -> impl Iterator<Item = &Self::Value>

Implementors§