peek_buffer#
- pride.utils.peek_buffer(buffer: bytes, contents_format: str, start: int) tuple[list[Any], int]#
Read and decode a sequence of bytes from a buffer
Starting from the start position, reads a portion of the buffer, and decodes it according to the format string. The amount of bytes to read is calculated automatically from the format string. The function returns the decoded contents, and the updated position from which to keep reading the buffer.
- Parameters:
buffer – Buffer of bytes to read from
contents_format – Format string to decode the bytes
start – Position from which to start reading the buffer
- Return contents:
Decoded contents
- Return current_byte:
Updated position from which to keep reading the buffer
- Raises:
BufferError – If it is not possible to calculate the number of bytes to read from the format string
BufferError – If the sum of the start position, and the calculated number of bytes to read is greater than the size of the buffer