"""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 = 0x32574152 PREPROC_MAGIC = 0x32525050 RESULT_MAGIC = 0x314C5352 def _write_interleaved_complex(buffer: bytearray, values: np.ndarray) -> None: """Append complex64 array as interleaved float32 real/imag pairs.""" interleaved = np.empty(values.size * 2, dtype=" 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.""" def serialize_payload(buffer: bytearray, payload) -> None: """Append one payload in ring-compatible result format.""" name_bytes = payload.processing_name.encode("utf-8") if len(name_bytes) > 0xFFFF: raise ValueError("processing_name is too long") buffer.extend(struct.pack("