Skip to content

Easy way to load an array #261

@XVilka

Description

@XVilka

For now Cstruct handles only strings/bytes when you call "copy/get" for fields with [@len N] attribute. It would be quite convenient to add something like

[%%cstruct
type qwe = {
   field1: uint16_t;
   field2: uint64_t [@len 16];
}
]

type myrec = {
   myrec1: int;
   myrec2: int64 array;
}

let load_struct buf =
   let cs_buf = Cstruct.of_bytes buf in
   {
     myrec1 = get_qwe_field1 cs_buf;
     myrec2 = array_qwe_field2 cs_buf;
   }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions