Skip to content

Commit 6da3a6c

Browse files
committed
Refactor the rust generator
This commit performs an overhaul of the rust generator which aims at improving the API of the generated code, to make it more readable and usable. The major changes are: - packet and struct have the same generated code. This also means that packet derivation is also supported for structs now - builder declarations are removed. The generator produces a unique struct for each packet that contains the immediate data fields, and fields copied from parent declarations - constrained fields do not appear in the generated struct, but an accessor is provided that returns the constant value for the field - the trait pdl_runtime::Packet is extended with the function decode() which parses the packet from an input slice and returns the remainder data - TryFrom trait implementations are provided for all child and parent packets; these exist mostly for convenience and do not aim to be performant
1 parent 3438474 commit 6da3a6c

File tree

172 files changed

+18905
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+18905
-18
lines changed

.github/workflows/build.yml

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ jobs:
9191
- name: Run Rust generator tests
9292
run: pdl-compiler/tests/run_rust_generator_tests.sh
9393

94+
- name: Run legacy Rust generator tests
95+
run: pdl-compiler/tests/run_rust_legacy_generator_tests.sh
96+
9497
- name: Run CXX generator tests
9598
run: pdl-compiler/tests/run_cxx_generator_tests.sh
9699

@@ -99,3 +102,6 @@ jobs:
99102

100103
- name: Compile Rust generated files
101104
run: pdl-compiler/tests/compile_rust_generated_files.sh
105+
106+
- name: Compile legacy Rust generated files
107+
run: pdl-compiler/tests/compile_rust_legacy_generated_files.sh

pdl-compiler/src/backends.rs

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
1717
pub mod intermediate;
1818
pub mod json;
19+
pub mod rust;
1920
pub mod rust_legacy;
2021
pub mod rust_no_allocation;

0 commit comments

Comments
 (0)