Value

Trait Value 

Source
pub trait Value: Sized {
    type Error: Debug + Error + Error;

    // Required methods
    fn from_typed<V: Serialize>(value: &V) -> Result<Self, Self::Error>;
    fn to_typed<'a, T: Deserialize<'a>>(&'a self) -> Result<T, Self::Error>;
}
Expand description

An abstraction over different value types, such as JSON or CBOR.

Required Associated Types§

Source

type Error: Debug + Error + Error

The error type returned when converting to or from the value type.

Required Methods§

Source

fn from_typed<V: Serialize>(value: &V) -> Result<Self, Self::Error>

Serialize a value to the value type.

Source

fn to_typed<'a, T: Deserialize<'a>>(&'a self) -> Result<T, Self::Error>

Deserialize a value from the value type.

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

Available on crate feature json only.
Source§

type Error = Error

Source§

fn from_typed<V: Serialize>(value: &V) -> Result<Self, Self::Error>

Source§

fn to_typed<'a, T: Deserialize<'a>>(&'a self) -> Result<T, Self::Error>

Implementors§