cbor_indefinite_len_array
Module for CBOR decoding/encoding indefinite length arrays. Indefinite length arrays are encoded without writing the array length, so elements shall be read until the termination byte is found.
NOTE: encoding of values greater than 2^64 is not supported.
- class CborIds(value)
Bases:
IntEnum
Enumerative for CBOR identifiers.
- UINT8 = 24
- UINT16 = 25
- UINT32 = 26
- UINT64 = 27
- INDEF_LEN_ARRAY_START = 159
- INDEF_LEN_ARRAY_END = 255
- class CborIndefiniteLenArrayConst
Bases:
object
Class container for CBOR indefinite length arrays constants.
- UINT_IDS_TO_BYTE_LEN: Dict[int, int] = {CborIds.UINT8: 2, CborIds.UINT16: 3, CborIds.UINT32: 5, CborIds.UINT64: 9}
- class CborIndefiniteLenArrayDecoder
Bases:
object
CBOR indefinite length arrays decoder. It decodes bytes back to array.
- static Decode(enc_bytes: bytes) List[int]
CBOR-decode the specified bytes.
- Parameters:
enc_bytes (bytes) – Encoded bytes
- Returns:
List of integers
- Return type:
list[int]
- Raises:
ValueError – If encoding is not valid
- class CborIndefiniteLenArrayEncoder
Bases:
object
CBOR indefinite length arrays encoder. It encodes indefinite length arrays to bytes.
- static Encode(int_seq: Sequence[int]) bytes
CBOR-encode the specified elements.
- Parameters:
int_seq (sequence[int]) – Collection of integers
- Returns:
CBOR-encoded bytes
- Return type:
bytes