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}

Summary

Functions

dump_binary(data, custom_type_args)

from_managed_to_unmanaged(managed, custom_type_args)

from_unmanaged_to_managed(unmanaged, custom_type_args)

init_args(custom_type_args)

known_total_size_bytes(custom_type_args)

module_code()

parse_exact_returning_options(bin, custom_type_args, options \\ nil)

parse_returning_options(bin, custom_type_args, opts)

size(data, custom_type_args)