Skip to main content

TryFromValue

Trait TryFromValue 

Source
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§

Source

type Error

The error type returned when the conversion fails.

Required Methods§

Source

fn try_from_value(v: &'a Value<S>) -> Result<Self, Self::Error>

Convert the Value with a specific schema type to the Rust 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 TryFromValue<'_, ED25519RComponent> for ComponentBytes

Source§

impl TryFromValue<'_, ED25519SComponent> for ComponentBytes

Source§

impl TryFromValue<'_, F64> for f64

Source§

impl TryFromValue<'_, F256BE> for f256

Source§

impl TryFromValue<'_, F256LE> for f256

Source§

impl TryFromValue<'_, GenId> for String

Source§

impl TryFromValue<'_, GenId> for Uuid

Source§

impl TryFromValue<'_, I256BE> for i8

Source§

impl TryFromValue<'_, I256BE> for i16

Source§

impl TryFromValue<'_, I256BE> for i32

Source§

impl TryFromValue<'_, I256BE> for i64

Source§

impl TryFromValue<'_, I256BE> for i128

Source§

impl TryFromValue<'_, I256BE> for I256

Source§

impl TryFromValue<'_, I256LE> for i8

Source§

impl TryFromValue<'_, I256LE> for i16

Source§

impl TryFromValue<'_, I256LE> for i32

Source§

impl TryFromValue<'_, I256LE> for i64

Source§

impl TryFromValue<'_, I256LE> for i128

Source§

impl TryFromValue<'_, I256LE> for I256

Source§

impl TryFromValue<'_, U256BE> for u8

Source§

impl TryFromValue<'_, U256BE> for u16

Source§

impl TryFromValue<'_, U256BE> for u32

Source§

impl TryFromValue<'_, U256BE> for u64

Source§

impl TryFromValue<'_, U256BE> for u128

Source§

impl TryFromValue<'_, U256BE> for U256

Source§

impl TryFromValue<'_, U256LE> for u8

Source§

impl TryFromValue<'_, U256LE> for u16

Source§

impl TryFromValue<'_, U256LE> for u32

Source§

impl TryFromValue<'_, U256LE> for u64

Source§

impl TryFromValue<'_, U256LE> for u128

Source§

impl TryFromValue<'_, U256LE> for U256

Source§

impl TryFromValue<'_, LineLocation> for (u64, u64, u64, u64)

Source§

impl TryFromValue<'_, R256BE> for Ratio<i128>

Source§

impl TryFromValue<'_, R256LE> for Ratio<i128>

Source§

impl TryFromValue<'_, RangeInclusiveU128> for (u128, u128)

Source§

impl TryFromValue<'_, RangeInclusiveU128> for RangeInclusive<u128>

Source§

impl TryFromValue<'_, RangeU128> for (u128, u128)

Source§

impl TryFromValue<'_, RangeU128> for Range<u128>

Source§

impl TryFromValue<'_, NsTAIInterval> for (i128, i128)

Source§

impl TryFromValue<'_, NsTAIInterval> for (Epoch, Epoch)

Source§

impl<'a> TryFromValue<'a, Boolean> for bool

Source§

impl<'a> TryFromValue<'a, ShortString> for &'a str

Source§

impl<'a> TryFromValue<'a, ShortString> for String

Source§

impl<'a, S: ValueSchema> TryFromValue<'a, S> for ()

Source§

impl<H> TryFromValue<'_, Hash<H>> for String
where H: HashProtocol,

Implementors§