Skip to main content

FromNeoValue

Trait FromNeoValue 

Source
pub trait FromNeoValue: Sized {
    // Required method
    fn from_value(value: &NeoValue) -> Result<Self, NeoError>;
}
Expand description

A type that can be deserialised from a NeoVM StackItem / NeoValue. This is the L9 IInteroperable equivalent in the C# devpack: any contract return type (or argument type) implements this trait, enabling NeoContract::call_typed<T> to round-trip the on-chain value into a typed Rust value.

The default from_value for the common types (NeoInteger, NeoBoolean, NeoByteString, NeoString) is provided; contract-specific types (e.g. a custom Token struct) can implement it by parsing the underlying NeoValue into the concrete type.

Required Methods§

Source

fn from_value(value: &NeoValue) -> Result<Self, NeoError>

Convert a NeoValue into Self. Returns an error if the value’s runtime type doesn’t match Self’s expected type (e.g. trying to extract an Integer from a String).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromNeoValue for ()

Source§

impl FromNeoValue for String

Source§

impl FromNeoValue for Vec<u8>

Source§

impl FromNeoValue for bool

Source§

impl FromNeoValue for i64

Implementors§