Merge "Revert "Revert "Update pdl-compiler to 0.1.4""" into main am: 864dc10f82 am: 8c91d72947

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pdl-compiler/+/2671115

Change-Id: I0c373697f15d550a6e7bfc73370949c6d98f3215
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: 897836674c74faac90707276de61c91a3c2e8c6b
  1. doc/
  2. examples/
  3. patches/
  4. scripts/
  5. src/
  6. tests/
  7. .cargo_vcs_info.json
  8. .gitignore
  9. Android.bp
  10. Cargo.toml
  11. Cargo.toml.orig
  12. cargo2android.json
  13. cargo2android_toplevel.bp
  14. CONTRIBUTING.md
  15. LICENSE
  16. METADATA
  17. MODULE_LICENSE_APACHE2
  18. OWNERS
  19. README.md
  20. rustfmt.toml
README.md

Packet Description Language (PDL)

Crate Build workflow GitHub contributors GitHub stars

PDL is a domain specific language for writing the definition of binary protocol packets. Parsing and validating packets from raw bytes is tedious and error prone in any language. PDL generates memory safe and tailored backends for multiple target languages:

- Rust
- C++
- Python

Historically PDL was developed as part of the Android Bluetooth stack (bluetooth_packetgen) as a way to generate the parser and serializer for Bluetooth packets, and reduce the number of memory safety issues that come with manipulating and validating raw data.

How to use PDL

  1. Write the protocol definition
  2. cargo run my-protocol.pdl --output-format rust > my-protocol.rs

Language specific instructions are provided for all supported backends:

  1. Rust generated code guide
  2. Python generated code guide
  3. C++ generated code guide

Supported Features

Full reference documentation

  • Scalar values
  • Enumerators
  • Arrays
  • Nested packets
  • Conditional packet derivation
  • Custom field definitions

Similar projects