Trait Value

Source
pub trait Value:
    Debug
    + Clone
    + Sized {
    type Error: Error;
    type MapType: Map<Value = Self>;

    // Required methods
    fn type_name(&self) -> &'static str;
    fn as_null(&self) -> Result<(), ValueError>;
    fn as_bool(&self) -> Result<bool, ValueError>;
    fn as_uint(&self) -> Result<u64, ValueError>;
    fn as_int(&self) -> Result<i64, ValueError>;
    fn as_float(&self) -> Result<f64, ValueError>;
    fn as_string(&self) -> Result<&str, ValueError>;
    fn as_array(&self) -> Result<&[Self], ValueError>;
    fn as_map(&self) -> Result<&Self::MapType, ValueError>;
    fn from_string(source: &str) -> Result<Self, Self::Error>;
}

Required Associated Types§

Source

type Error: Error

Source

type MapType: Map<Value = Self>

Required Methods§

Source

fn type_name(&self) -> &'static str

Source

fn as_null(&self) -> Result<(), ValueError>

Source

fn as_bool(&self) -> Result<bool, ValueError>

Source

fn as_uint(&self) -> Result<u64, ValueError>

Source

fn as_int(&self) -> Result<i64, ValueError>

Source

fn as_float(&self) -> Result<f64, ValueError>

Source

fn as_string(&self) -> Result<&str, ValueError>

Source

fn as_array(&self) -> Result<&[Self], ValueError>

Source

fn as_map(&self) -> Result<&Self::MapType, ValueError>

Source

fn from_string(source: &str) -> Result<Self, Self::Error>

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

Source§

impl Value for Value

Source§

impl Value for Yaml

Implementors§