Serializer

Binary serializer that generates contiguous structs. It recursively iterates over struct fields copying any array contents into the same byte buffer and clear the array pointer field. Latter is done to avoid accidental access via dangling pointer once that data is read from external source.

Arrays of arrays are stored with small optimization, keeping only length part of the slice (as .ptr will be always null)

Deserializer later does similar iteration updating all internal pointers.

Members

Aliases

This
alias This = typeof(this)

Convenience shortcut

Static functions

countRequiredSize
size_t countRequiredSize(S input)

Return the serialized length of input

resetArrayReferences
T[] resetArrayReferences(T[] array)

Resets all dynamic arrays in all elements of array to null.

serialize
void[] serialize(S src, Buffer!(void) dst)
void[] serialize(S src, D[] dst)

Serializes the data in src.

serialize
void[] serialize(Contiguous!(S) src)

In-place serialization that takes advantage of the fact Contiguous instances already have required data layout. All arrays within src will be reset to null (and their length to 0) making their data unreachable from original struct. This is done to minimize risk of dangling array pointers.

Meta