jam.utils.codec.primitives.bytes module

Codec for byte sequences.

class jam.utils.codec.primitives.bytes.BytesCodec[source]

Bases: Codec

Codec for variable-length byte sequences.

encode_size(value: bytes) int[source]

Calculate encoded size of a byte sequence.

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

Encode a byte sequence into a buffer.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0) Tuple[bytes, int][source]

Decode a byte sequence from a buffer.

class jam.utils.codec.primitives.bytes.FixedBytesCodec(size: int)[source]

Bases: Codec

Codec for fixed-length byte sequences.

__init__(size: int)[source]

Initialize with fixed size.

encode_size(value: bytes) int[source]

Calculate encoded size of a byte sequence.

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

Encode a byte sequence into a buffer.

static decode_from(buffer: bytes | bytearray | memoryview, offset: int = 0, size: int = 0) Tuple[bytes, int][source]

Decode a byte sequence from a buffer.