pub trait RawValConvertible: Into<RawVal> + TryFrom<RawVal> {
    // Required methods
    fn is_val_type(v: RawVal) -> bool;
    unsafe fn unchecked_from_val(v: RawVal) -> Self;

    // Provided method
    fn try_convert(v: RawVal) -> Option<Self> { ... }
}
Expand description

Trait abstracting over types that can be converted into RawVal, similar to TryFrom but with a different signature that enables generating slightly more efficient conversion code. An implementation of TryFrom<Val> is also provided for any type that implements ValConvertible.

Required Methods§

source

fn is_val_type(v: RawVal) -> bool

Returns true if v is in a union state compatible with Self.

source

unsafe fn unchecked_from_val(v: RawVal) -> Self

Converts the bits making up a Val into Self without checking that the Val is tagged correctly, assuming that such a check has been performed elsewhere. It is the caller’s responsibility to arrange that such checks have occurred before calling unchecked_from_val, which is why it is marked as unsafe (it does not represent a risk of memory-unsafety, merely “serious logic errors”).

Provided Methods§

source

fn try_convert(v: RawVal) -> Option<Self>

Attempt a conversion from Val to Self, returning None if the provided Val is not tagged correctly. By default this calls Self::is_val_type and Self::unchecked_from_val, but it can be customized on a type-by-type basis to avoid redundant tag tests and produce more efficient code, as it is done for Static values like bool.

Implementations on Foreign Types§

source§

impl RawValConvertible for bool

source§

impl RawValConvertible for i32

source§

impl RawValConvertible for ()

source§

impl RawValConvertible for u32

Implementors§

source§

impl RawValConvertible for AddressObject

source§

impl RawValConvertible for Bool

source§

impl RawValConvertible for BytesObject

source§

impl RawValConvertible for ContractExecutableObject

source§

impl RawValConvertible for DurationObject

source§

impl RawValConvertible for DurationSmall

source§

impl RawValConvertible for DurationVal

source§

impl RawValConvertible for I32Val

source§

impl RawValConvertible for I64Object

source§

impl RawValConvertible for I64Small

source§

impl RawValConvertible for I64Val

source§

impl RawValConvertible for I128Object

source§

impl RawValConvertible for I128Small

source§

impl RawValConvertible for I128Val

source§

impl RawValConvertible for I256Object

source§

impl RawValConvertible for I256Small

source§

impl RawValConvertible for I256Val

source§

impl RawValConvertible for LedgerKeyNonceObject

source§

impl RawValConvertible for MapObject

source§

impl RawValConvertible for Object

source§

impl RawValConvertible for Status

source§

impl RawValConvertible for StringObject

source§

impl RawValConvertible for Symbol

source§

impl RawValConvertible for SymbolObject

source§

impl RawValConvertible for SymbolSmall

source§

impl RawValConvertible for TimepointObject

source§

impl RawValConvertible for TimepointSmall

source§

impl RawValConvertible for TimepointVal

source§

impl RawValConvertible for U32Val

source§

impl RawValConvertible for U64Object

source§

impl RawValConvertible for U64Small

source§

impl RawValConvertible for U64Val

source§

impl RawValConvertible for U128Object

source§

impl RawValConvertible for U128Small

source§

impl RawValConvertible for U128Val

source§

impl RawValConvertible for U256Object

source§

impl RawValConvertible for U256Small

source§

impl RawValConvertible for U256Val

source§

impl RawValConvertible for VecObject

source§

impl RawValConvertible for Void