[go: up one dir, main page]

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:

  1. Do some minor modifications of lib-kaitai.
  2. Initialize lib-kaitai-of-data-encoding inside manifest.
  3. Define automatic translations for the Data_encoding.uint8 ground 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-encoding support:
    • !9882 (merged) - Add support for bool type and nested tuples.
    • !9748 (merged) - Add support for bytes, string, and variable length numeric types.
  • !9848 (merged) - Add command to octez-codec for dumping kaitai spec files out of registered encodings.

Manually testing the MR

Testing that automatic translation of Data_encoding.uint8:

  1. Install kaitai-struct-compiler (see your package manager, or official downloads) or use the official web ide.
  2. Store the kaitai spec from the test in a file (e.g., ground_uint8.ksy):
    meta:
      id: ground_uint8
    seq:
    - id: uint8
      type: u1
  1. Generate a parser in rust running the following command:
kaitai-struct-compiler ground_uint8.ksy -t rust
  1. Check that you obtained a rust source file ground_uint8.rs.

  2. Generate exemplary hex dump:

./octez-codec encode ground.uint8 from 255
ff
  1. Generate ground_uint8.bin file from the hex dump from 4.. E.g. use xxd command.

  2. Ensure the parser from 3./4. (ground_uint8.rs) is able to parse ground_uint8.bin file from 5./6..

Edited by Raphaël Proust

Merge request reports

Loading