pub trait FromValue<'v> {
// Required method
fn from_value(value: Value<'v>) -> Option<Self>
where Self: Sized;
}Expand description
Convert from a Value.
This trait is the basis for the Value::cast method.
This may involve downcasting, serializing, or parsing. Implementations should attempt to downcast first with Value::downcast_ref.
§Relationship with From<Value>
This trait is similar to the standard From trait, but serves a different purpose. The From trait is infallible, and since Value could be anything only a handful of types implement it. FromValue is fallible, so more types can implement it, returning None when the contained value is incompatible.
Required Methods§
Sourcefn from_value(value: Value<'v>) -> Option<Self>where
Self: Sized,
fn from_value(value: Value<'v>) -> Option<Self>where
Self: Sized,
Perform the conversion.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".