BinStruct.BuiltIn.Recursive (bin_struct v0.2.16)
A custom type for handling recursive structures within BinStruct
.
Overview
The Recursive
custom type is designed to facilitate parsing, size computation, and binary serialization
of nested or recursive structures in a way that allows the library to manage recursion efficiently.
Instead of relying on the library to directly introspect recursive types during compile-time analysis, this module enables wrapping a recursive type with a custom definition. By doing so, it delegates the responsibility of compile-time introspection to the custom type itself. This allows for more precise control over how the recursive type is handled and provides an avenue for customization in the future (though such customization is not yet implemented).
Example Usage
Instead of declaring a recursive type directly:
field :sequence, Sequence
Wrap the recursive type with Recursive:
field :sequence, {Recursive, module: Sequence}