VariantValue

Trait VariantValue 

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

    // Required methods
    fn is_null(&self) -> bool;
    fn is_boolean(&self) -> bool;
    fn is_string(&self) -> bool;
    fn is_array(&self) -> bool;
    fn is_object(&self) -> bool;
    fn as_bool(&self) -> Option<bool>;
    fn as_str(&self) -> Option<&str>;
    fn as_array(&self) -> Option<&Self::VariantArray>;
    fn as_object(&self) -> Option<&Self::VariantObject>;
    fn is_less_than(&self, other: &Self) -> bool;
    fn is_equal_to(&self, other: &Self) -> bool;
}
Expand description

A trait for any variant value.

Required Associated Types§

Source

type VariantArray: ConcreteVariantArray<Value = Self>

The type of the array variant.

Source

type VariantObject: ConcreteVariantObject<Value = Self>

The type of the object variant.

Required Methods§

Source

fn is_null(&self) -> bool

Whether the value is a null.

Source

fn is_boolean(&self) -> bool

Whether the value is a boolean.

Source

fn is_string(&self) -> bool

Whether the value is a number.

Source

fn is_array(&self) -> bool

Whether the value is an array.

Source

fn is_object(&self) -> bool

Whether the value is an object.

Source

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

Convert the value to a bool; None if the value is not an array.

Source

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

Convert the value to a str; None if the value is not a string.

Source

fn as_array(&self) -> Option<&Self::VariantArray>

Convert the value to an array; None if the value is not an array.

Source

fn as_object(&self) -> Option<&Self::VariantObject>

Convert the value to an object; None if the value is not an object.

Source

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

Whether self is less than another value.

Source

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

Whether self is equal to another value.

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 VariantValue for Value

Available on crate feature json only.
Source§

type VariantArray = Vec<Value>

Source§

type VariantObject = Map<String, Value>

Source§

fn is_null(&self) -> bool

Source§

fn is_boolean(&self) -> bool

Source§

fn is_string(&self) -> bool

Source§

fn is_array(&self) -> bool

Source§

fn is_object(&self) -> bool

Source§

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

Source§

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

Source§

fn as_array(&self) -> Option<&Self::VariantArray>

Source§

fn as_object(&self) -> Option<&Self::VariantObject>

Source§

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

Source§

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

Source§

impl VariantValue for Value

Available on crate feature toml only.
Source§

type VariantArray = Vec<Value>

Source§

type VariantObject = Map<String, Value>

Source§

fn is_null(&self) -> bool

Source§

fn is_boolean(&self) -> bool

Source§

fn is_string(&self) -> bool

Source§

fn is_array(&self) -> bool

Source§

fn is_object(&self) -> bool

Source§

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

Source§

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

Source§

fn as_array(&self) -> Option<&Self::VariantArray>

Source§

fn as_object(&self) -> Option<&Self::VariantObject>

Source§

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

Source§

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

Implementors§