"""Binary payload serialization for sweep/result collections.""" from __future__ import annotations import struct import numpy as np from python_app.models.dataset_model import ResultCollection, SweepCollection RAW_MAGIC = 0x31574152 PREPROC_MAGIC = 0x31525050 RESULT_MAGIC = 0x314C5352 def serialize_trace_collection(collection: SweepCollection, magic: int) -> bytes: """Serialize one raw/preprocessed trace collection into ring-compatible binary format.""" buffer = bytearray() buffer.extend( struct.pack(" bytes: """Serialize one processed collection with result blocks/payloads.""" buffer = bytearray() buffer.extend( struct.pack(" 0xFFFF: raise ValueError("processing_name is too long") buffer.extend(struct.pack("