Skip to content

Latest commit

 

History

History
86 lines (42 loc) · 2.19 KB

cbor.md

File metadata and controls

86 lines (42 loc) · 2.19 KB

Module 0x2::cbor

Constants

Error if the CBOR bytes are invalid

const ERROR_INVALID_CBOR_BYTES: u64 = 1;

Function from_cbor

Function to deserialize a type T from CBOR bytes.

#[data_struct(#[T])]
public fun from_cbor<T: drop>(bytes: vector<u8>): T

Function from_cbor_option

Function to deserialize a type T from CBOR bytes. If the CBOR bytes are invalid, it will return None.

#[data_struct(#[T])]
public fun from_cbor_option<T: drop>(bytes: vector<u8>): option::Option<T>

Function to_map

Parse a cbor object bytes to a SimpleMap If the cbor bytes is invalid, it will return an empty SimpleMap If the field type is primitive type, it will be parsed to bytes, array or object will be parsed to cbor bytes

Function to_cbor

Serialize a value of type T to CBOR bytes.

public fun to_cbor<T>(value: &T): vector<u8>