The easiest way to encode data items is using the cbor_serialize
or cbor_serialize_alloc
functions:
cbor_serialize
cbor_serialize_alloc
In case you know the type of the item you want to serialize beforehand, you can use one of the type-specific serializers.
Note
Unless compiled in debug mode, these do not verify the type. Passing an incorrect item will result in an undefined behavior.
cbor_serialize_uint
cbor_serialize_negint
cbor_serialize_bytestring
cbor_serialize_string
cbor_serialize_array
cbor_serialize_map
cbor_serialize_tag
cbor_serialize_float_ctrl