sbe-codegen

Crates.iosbe-codegen
lib.rssbe-codegen
version
sourcesrc
created_at2024-10-19 10:44:56.90253
updated_at2024-10-19 10:44:56.90253
descriptionPerformance-oriented multi-language SBE codec generator
homepagehttps://github.com/python-systems/sbe-codegen
repositoryhttps://github.com/python-systems/sbe-codegen
max_upload_size
id1415252
Cargo.toml error:TOML parse error at line 19, column 1 | 19 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Jakub Kubík (M0dEx)

documentation

README

sbe-codegen

sbe-codegen is a tool to generate language-specific codecs for data structures encoded using Simple Binary Encoding.

Supported languages

  • ✅ Rust
  • ✅ Python
  • ❌ Java/Kotlin

Installation

sbe-codegen can be installed either by building from sources directly or by downloading from the JFrog crates repository.

MSRV (Minimum Supported Rust Version)

The MSRV for sbe-codegen is 1.73.0. This means that sbe-codegen will compile with any version of Rust greater than or equal to 1.73.0.

The code generation is currently broken on the stable channel due to certain features being unstable.

Downloading from crates

You can install the latest version of sbe-codegen by running:

$ cargo install sbe-codegen

Building from sources

Assuming you have this repository checked-out locally, you can build sbe-codegen by running:

$ cargo build --release

Usage

$ sbe-codegen --help
SBE multi-language codec generator

Usage: sbe-codegen [OPTIONS] --schema <SCHEMA_PATH> --language <LANGUAGE> --project-name <PROJECT_NAME> --project-path <PROJECT_PATH>

Options:
      --schema <SCHEMA_PATH>         Path to XML SBE schema
      --language <LANGUAGE>          Codec language [possible values: rust, python]
      --project-name <PROJECT_NAME>  Project name
      --project-path <PROJECT_PATH>  Project path
      --project-version <VERSION>    Project version (optional, taken from schema if not specified)
      --with-test-deps               Include test dependencies
      --format                       Format project
  -h, --help                         Print help

Codec generation

The following command generates Rust codecs for the example schema in the examples directory:

$ sbe-codegen --schema ./examples/example-schema.xml --language rust --project-name example --project-path ./examples/rust --with-test-deps --format

The Python codecs similarly can be generated by running:

$ sbe-codegen --schema ./examples/example-schema.xml --language python --project-name example --project-path ./examples/python --format

Codec compilation

The Rust codecs then can be compiled by running:

$ cd ./examples/rust
$ cargo build --release

Similarly, the Python codecs can be compiled by running (maturin is required):

$ cd ./examples/python
$ maturin build --release

Example usage of generated codecs

Usage examples of the generated codecs can be found in the tests provided in the examples/rust/tests (Rust) or examples/python/tests (Python) directories.

If you want to test the generated codecs, generate them with the --with-test-deps flag and run the tests with:

$ cd ./examples/rust
$ cargo test
$ cd ./examples/python
$ poetry install
$ maturin dev #--release (for benchmarks)
$ pytest
Commit count: 3

cargo fmt