DataKit icon indicating copy to clipboard operation
DataKit copied to clipboard

Unable to use a variable length structure

Open brutella opened this issue 1 year ago • 0 comments

How would I use DataKit to encode a variable length structure?

My bytes representation looks like this.

( 1 Byte )
[ Length ][ Type ][ ID ][ Version ]...[ ID ][ Version ]

(Length is the overall byte count.)

I've tried to create a struct but I'm unable to provide a write format.

typealias ID = UInt8
typealias Version = UInt8
struct InfoBlock {
    let blockType: UInt8
    let values: [ID:Version]
}

How would the format look like to map it to the above mentioned bytes representation?

Thanks for the help.

brutella avatar Nov 21 '24 10:11 brutella