Hi all,
I'm just trying out very promising construct library, which I've just discovered.
I'm reading the docs, but can't find some pieces.
I'm going to define some "data types". Like (example):
STRING = Struct("STRING",
UBInt8("length"),
Bytes("data", lambda ctx: ctx.length),
)
I am going to receive list of formats and list of data - I will then build them together.
Like:
data = [1, "str", 2]
formats = [UBInt8, STRING, UBInt8]
I'm not interested in the name, so for 1st and 3rd element it would be:
formats[n]('foo').build(data[n])
But the Struct is already initialized (right?) and I can't "call" it.
What's the way to achieve that?
Additionally, when composing Struct of smaller Structs I don't know how to do that:
BIGGER = Struct("name",
UBInt8("something"),
STRING,
STRING)
^^ that will fail
How can I put several structs in one struct?
Regards,
Robert