Source from https://github.com/aptos-labs/aptos-core/blob/main/aptos-move/framework/aptos-stdlib/sources/from_bcs.move
This module provides a number of functions to convert primitive types from their representation in std::bcs
to values. This is the opposite of bcs::to_bytes
. Note that it is not safe to define a generic public from_bytes
function because this can violate implicit struct invariants, therefore only primitive types are offerred. If
a general conversion back-and-force is needed, consider the moveos_std::Any
type which preserves invariants.
- Constants
- Function
to_bytes
- Function
to_bool
- Function
to_u8
- Function
to_u64
- Function
to_u128
- Function
to_address
- Function
from_bytes
- Function
native_from_bytes
use 0x1::bcs;
The request Move type is not match with input Move type.
const ErrorTypeNotMatch: u64 = 1;
public fun to_address(v: vector<u8>): address
Function to deserialize a type T.
Note the private_generics
ensure only the MoveValue
's owner module can call this function
#[data_struct(#[MoveValue])]
public fun from_bytes<MoveValue>(bytes: vector<u8>): MoveValue
public(friend) fun native_from_bytes<MoveValue>(bytes: vector<u8>): MoveValue