Class StructuredRecordArraySerializer
Minimal, dependency-free binary serializer for an array of StructuredRecord.
Implements
Inherited Members
Namespace: Serenity.StructuredPersistence.Infrastructure.KeyValue
Assembly: Serenity.StructuredPersistence.KeyValue.dll
Syntax
public class StructuredRecordArraySerializer : ISerializer<StructuredRecord[]>
Remarks
The engine-agnostic layer has no existing ISerializer<T> implementation to
reuse for structured records: UnityEngine.JsonUtility is unavailable outside Unity
assemblies, and pulling in YamlDotNet would add a heavier dependency than this store needs.
This hand-rolled binary format keeps KeyValueStructuredStore self-contained and
trivially round-trip-testable.
Payload layout: a format-version int (currently 1), a record-count int, then each record's nullable id, field count, and per-field name/kind-byte/value. Deserialize(ReadOnlySpan<byte>) validates every length it reads and throws a descriptive InvalidDataException on an unknown version, an implausible count, or truncation, so a corrupt payload is reported loudly to the caller (the store converts it into a warning plus an empty partition) instead of producing garbage records.
Constructors
StructuredRecordArraySerializer()
Declaration
public StructuredRecordArraySerializer()
Methods
Deserialize(ReadOnlySpan<byte>)
Declaration
public StructuredRecord[] Deserialize(ReadOnlySpan<byte> bytes)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | bytes |
Returns
| Type | Description |
|---|---|
| StructuredRecord[] |
Exceptions
| Type | Condition |
|---|---|
| InvalidDataException | Thrown when the payload declares an unknown format version, an implausible count, or ends before it is fully read. |
Serialize(StructuredRecord[])
Declaration
public byte[] Serialize(StructuredRecord[] value)
Parameters
| Type | Name | Description |
|---|---|---|
| StructuredRecord[] | value |
Returns
| Type | Description |
|---|---|
| byte[] |