pub trait TryFromValue<'a, S: ValueSchema>: Sized {
type Error;
// Required method
fn try_from_value(v: &'a Value<S>) -> Result<Self, Self::Error>;
}Expand description
A trait for converting a Value with a specific schema type to a Rust type. This trait is implemented on the concrete Rust type.
Values are 32-byte arrays that represent data at a deserialization boundary.
Conversions may fail depending on the schema and target type. Use
Error = Infallible for conversions that genuinely cannot fail (e.g.
ethnum::U256 from U256BE), and a real error type for narrowing
conversions (e.g. u64 from U256BE).
This is the counterpart to the TryToValue trait.
See TryFromBlob for the counterpart trait for blobs.
Required Associated Types§
Required Methods§
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.