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§
Sourcetype VariantArray: ConcreteVariantArray<Value = Self>
type VariantArray: ConcreteVariantArray<Value = Self>
The type of the array variant.
Sourcetype VariantObject: ConcreteVariantObject<Value = Self>
type VariantObject: ConcreteVariantObject<Value = Self>
The type of the object variant.
Required Methods§
Sourcefn is_boolean(&self) -> bool
fn is_boolean(&self) -> bool
Whether the value is a boolean.
Sourcefn as_bool(&self) -> Option<bool>
fn as_bool(&self) -> Option<bool>
Convert the value to a bool; None if the value is not an array.
Sourcefn as_str(&self) -> Option<&str>
fn as_str(&self) -> Option<&str>
Convert the value to a str; None if the value is not a string.
Sourcefn as_array(&self) -> Option<&Self::VariantArray>
fn as_array(&self) -> Option<&Self::VariantArray>
Convert the value to an array; None if the value is not an array.
Sourcefn as_object(&self) -> Option<&Self::VariantObject>
fn as_object(&self) -> Option<&Self::VariantObject>
Convert the value to an object; None if the value is not an object.
Sourcefn is_less_than(&self, other: &Self) -> bool
fn is_less_than(&self, other: &Self) -> bool
Whether self is less than another value.
Sourcefn is_equal_to(&self, other: &Self) -> bool
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.
impl VariantValue for Value
Available on crate feature
json only.type VariantArray = Vec<Value>
type VariantObject = Map<String, Value>
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
Source§impl VariantValue for Value
Available on crate feature toml only.
impl VariantValue for Value
Available on crate feature
toml only.