jam.utils.codec.composite.arrays module

Array codec implementation for JAM specification.

Arrays are encoded by concatenating their encoded elements with no length prefix. The length is known at compile-time in Rust; in Python we enforce it at runtime. Maximum array size is 1000 elements as per specification.

class jam.utils.codec.composite.arrays.ArrayCodec(length: int)[source]

Bases: Codec[Sequence[Codable]]

Codec for fixed-length arrays/sequences.

Arrays are encoded by concatenating their encoded elements in order. The length is fixed and known at encoding/decoding time.

MAX_SIZE = 1000
__init__(length: int)[source]
length: int
encode_size(value: Sequence[Codable]) int[source]

Calculate the number of bytes needed to encode the value.

encode_into(value: Sequence[Codable], buffer: bytearray, offset: int = 0) int[source]

Encode the value into the provided buffer at the specified offset.

static decode_from(length: int, codable_class: type[Codable], buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[List, int][source]

Decode a value from the provided buffer starting at the specified offset.