Client-libs: Init kaitai-of-data-encoding lib
Context
Follows !9750 (merged).
See handling data encoding of client-libs
.
This MR introduces lib-kaitai-of-data-encoding library. The goal of this library is to translate from a valid Data_encoding.t definition to a Kaitai specification AST.
In this MR we do the following:
- Do some minor modifications of
lib-kaitai. - Initialize
lib-kaitai-of-data-encodinginside manifest. - Define automatic translations for the
Data_encoding.uint8ground type to a valid Kaitai specification. This is merely to show that the scaffolding holds. Further types are supported in follow-up MRs.
Notice, we have to manually ensure that a generated Kaitai specification is valid. Later on tests will cover this automatically.
Follow-up
There are two orhogonal axis of work:
- Extending
kaitai-of-data-encodingsupport:-
!9882 (merged) - Add support for
booltype and nested tuples. -
!9748 (merged) - Add support for
bytes,string, and variable length numeric types.
-
!9882 (merged) - Add support for
-
!9848 (merged) - Add command to
octez-codecfor dumping kaitai spec files out of registered encodings.
Manually testing the MR
Testing that automatic translation of Data_encoding.uint8:
- Install kaitai-struct-compiler (see your package manager, or official downloads) or use the official web ide.
- Store the kaitai spec from the test in a file (e.g.,
ground_uint8.ksy):
meta:
id: ground_uint8
seq:
- id: uint8
type: u1
- Generate a parser in rust running the following command:
kaitai-struct-compiler ground_uint8.ksy -t rust
-
Check that you obtained a rust source file
ground_uint8.rs. -
Generate exemplary hex dump:
./octez-codec encode ground.uint8 from 255
ff
-
Generate
ground_uint8.binfile from the hex dump from 4.. E.g. usexxdcommand. -
Ensure the parser from 3./4. (
ground_uint8.rs) is able to parseground_uint8.binfile from 5./6..
Edited by Raphaël Proust