Trait MoveType

Source
pub trait MoveType:
    Clone
    + Debug
    + Display
    + for<'de> Deserialize<'de>
    + Serialize
    + PartialEq
    + Eq
    + Hash {
    type TypeTag: MoveTypeTag;

    // Provided methods
    fn from_bcs(bytes: &[u8]) -> Result<Self> { ... }
    fn into_bcs(self) -> Result<Vec<u8>> { ... }
    fn to_bcs(&self) -> Result<Vec<u8>> { ... }
    fn into_json(self) -> Value { ... }
    fn to_json(&self) -> Value { ... }
}
Expand description

Trait marking a Move data type. Has a specific way to construct a TypeTag.

Required Associated Types§

Provided Methods§

Source

fn from_bcs(bytes: &[u8]) -> Result<Self>

Deserialize the contents of the Move type from BCS bytes.

Source

fn into_bcs(self) -> Result<Vec<u8>>

Consuming version of to_bcs.

Source

fn to_bcs(&self) -> Result<Vec<u8>>

Serialize the contents of the Move type to BCS bytes.

Source

fn into_json(self) -> Value

Consuming version of to_json.

Source

fn to_json(&self) -> Value

Serialize the contents of the Move type to JSON.

The method takes care to use JSON String representations for integer types, for which serde would use Number.

This is useful for interacting with the RPC.

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 MoveType for bool

Source§

impl MoveType for u8

Source§

impl MoveType for u16

Source§

impl MoveType for u32

Source§

impl MoveType for u64

Source§

impl MoveType for u128

Source§

impl MoveType for String

Source§

impl MoveType for U256

Source§

impl MoveType for Address

Implementors§