Snap for 12134224 from 1136cdb7dd9b4e35a13ae988663ce487ae7884b6 to simpleperf-release

Change-Id: I0d238af195f8ca4a745b4f855cc9fe62eebd3969
tree: 77f8cca5250ed5628d58411e095ab2079f34ebce
  1. patches/
  2. scripts/
  3. src/
  4. tests/
  5. .cargo_vcs_info.json
  6. .gitignore
  7. Android.bp
  8. Cargo.toml
  9. Cargo.toml.orig
  10. cargo2android_toplevel.bp
  11. cargo_embargo.json
  12. LICENSE
  13. METADATA
  14. MODULE_LICENSE_APACHE2
  15. OWNERS
  16. README.md
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
  • Optional fields
  • Nested packets
  • Conditional packet derivation
  • Custom field definitions

Similar projects