Creates the struct and optionally fills it with data. If data is provided, the length of the provided buffer needs to match the structure length.
This method is stripped from type on struct build()
.
Optional
data: BufferReturns total length of the struct. Struct length is always fixed and configured
by calls to member()
methods.
Adds a numeric member of uint8
, uint16
or uint32
type.
Internal representation is always little endian.
This method is stripped from type on struct build()
.
Underlying data type (uint8, uint16 or uint32).
Name of the struct member.
Adds an uint8 array (byte array) as a struct member.
This method is stripped from type on struct build()
.
Underlying data type. Must be uint8array
.
Name of the struct member.
Length of the byte array.
Adds another struct type as a struct member. Struct factory is provided as a child struct definition source.
This method is stripped from type on struct build()
.
Underlying data type. Must be struct
.
Name of the struct member.
Factory providing the wanted child struct.
Returns raw contents of the structure as a sliced Buffer. Mutations to the returned buffer will not be reflected within struct.
Static
new
Struct provides a builder-like interface to create Buffer-based memory structures for read/write interfacing with data structures from adapters.