construct-typing icon indicating copy to clipboard operation
construct-typing copied to clipboard

Document examples of using nested Structs and Unions with DataclassMixin

Open lindblandro opened this issue 2 years ago • 0 comments

I'm trying to convert old construct code to be more readable and DataclassMixin seems the way to do it. However, I converting nested structures into dataclass instances is a bit hazy for me at the moment. Is it possible to describe a structure like

Struct(
    "field" / Int8ub,
    "foo" / Union(
        "bar" / Int24ub,
        "baz" / Struct(
            "a" / Int8ub,
            "b" / Int8ub,
            "c" / Int8ub
        )
    )
)

into a DataclassMixin?

lindblandro avatar Mar 01 '22 07:03 lindblandro