jam.utils.codec.utils module
- jam.utils.codec.utils.check_buffer_size(buffer: bytes | bytearray | memoryview, expected: int, offset: int = 0) None[source]
Check if a buffer has enough remaining space.
- Parameters:
buffer – The buffer to check
expected – The number of bytes needed
offset – Starting position in the buffer
- Raises:
EncodeError – If the buffer is too small
- jam.utils.codec.utils.ensure_size(buffer: bytes | bytearray | memoryview, expected: int, offset: int = 0) None[source]
Ensure a buffer has enough bytes available for reading.
- Parameters:
buffer – The buffer to check
expected – The number of bytes needed
offset – Starting position in the buffer
- Raises:
DecodeError – If the buffer is too small