| Crates.io | sbe-codegen |
| lib.rs | sbe-codegen |
| version | 0.1.0 |
| created_at | 2024-10-19 10:44:56.90253+00 |
| updated_at | 2024-10-19 10:44:56.90253+00 |
| description | Performance-oriented multi-language SBE codec generator |
| homepage | https://github.com/python-systems/sbe-codegen |
| repository | https://github.com/python-systems/sbe-codegen |
| max_upload_size | |
| id | 1415252 |
| size | 271,032 |
sbe-codegen is a tool to generate language-specific codecs for data structures encoded using Simple Binary Encoding.
sbe-codegen can be installed either by building from sources directly or by downloading from the JFrog crates repository.
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.
You can install the latest version of sbe-codegen by running:
$ cargo install sbe-codegen
Assuming you have this repository checked-out locally, you can build sbe-codegen by running:
$ cargo build --release
$ 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
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
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
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