Type alias definition
Convenience shortcut
Maximum allowed dynamic array length. If any dynamic array is longer than this value, a DeserializationException is thrown.
Calculates total amount of bytes needed for an array to store deserialized S instance.
Deserializes src in-place. If array branching is needed, length of src will be increased to be able to store those.
Identical to contiguous.Deserializer.deserialize but instead of modifying input buffer copies the deserialized data to provided Contiguous wrapper.
static asserts that T has no qualifier.
struct Test { int a; int[] b; } // in-place void[] input = getFromExternalSource(); Contiguous!(Test) s1 = Deserializer.deserialize(input); assert(s1.ptr is input.ptr); // don't modify original source Contiguous!(Test) target; Contiguous!(Test) s2 = Deserializer.deserialize(input, target); assert(s2.ptr is target.ptr); assert(s2.ptr !is input.ptr);
Binary deserializer that operates on Contiguous structs
It operates on data buffers generated by calling matching Serializer or ones with an identicaly binary layout. Deserialization process is relatively simple and requires iteration over the struct and updating array fields to point to internal buffer slices.
The contents of dynamic arrays are stored in the buffer with the array length prepended. For dynamic arrays of dynamic arrays that means that only one single length field gets stored for each top-level array. When such an array is encountered the Deserializer needs to extend the buffer and put the expanded array slice (with all ppointers restored) to the end. This process is called "array branching".
All deserialization methods that return a struct instance or a pointer use in fact one of the argument data buffers as backing memory storage. Modifying those directly will invalidate/corrupt your struct pointer.
Deserialized structures can be written to, as well as any referenced arrays / structures. However, resizing arrays (i.e. appending) will cause the buffer to be reallocated, causing the struct to no longer be contiguous. As contiguity invariant is disabled by default that may result in undefined behaviour.
For copying structures obtained via deserialization you must use the copy function defined above in this module.