Trait merde::ValueDeserialize
source · pub trait ValueDeserialize<'s>: Sized {
// Required method
fn from_value_ref<'val>(
value: Option<&'val Value<'s>>,
) -> Result<Self, MerdeError>;
// Provided method
fn from_value(value: Option<Value<'s>>) -> Result<Self, MerdeError> { ... }
}Expand description
Types that can be deserialized from a Value.
Implementations are provided for primitive types, strings, arrays,
[HashMap], Option, etc.
There is no facility for “parsing strings as numbers”. However, this
implementation does support numbers that are too big to fit (precisely) in
an f64, ie. integers larger than 2**53.
A field of type HashMap<K, V> or Vec<T> is required! If you want to make it optional,
wrap it in an Option<T> explicitly, e.g. Option<HashMap<K, V>> or Option<Vec<T>>.
Required Methods§
sourcefn from_value_ref<'val>(
value: Option<&'val Value<'s>>,
) -> Result<Self, MerdeError>
fn from_value_ref<'val>( value: Option<&'val Value<'s>>, ) -> Result<Self, MerdeError>
Destructures a Value into a more structured type
Provided Methods§
sourcefn from_value(value: Option<Value<'s>>) -> Result<Self, MerdeError>
fn from_value(value: Option<Value<'s>>) -> Result<Self, MerdeError>
Destructures a JSON value into a Rust value, while taking ownership of the Value. A default implementation is provided, but some types may want to implement it themselves to avoid unnecessary allocations/cloning.
Object Safety§
This trait is not object safe.