def read_int_list_from_buf(data: ByteString, offset) -> Tuple[List[int], int]: elems = [] elems_count, offset = read_varint_from_buf(data, offset) for idx in range(elems_count): elem, offset = read_varint_from_buf(data, offset) elems.append(elem) return elems, offset
def read_bytes_from_buf(data: ByteString, offset) -> Tuple[bytearray, int]: data_len, offset = read_varint_from_buf(data, offset) if offset + data_len >= len(data): raise ValueError('Corrupted data found.') return data[offset:offset + data_len], offset + data_len