Clone this repo:
  1. 8ced8b9 Upgrade pdl-runtime to 0.2.3 am: b91ba5464b by Jeff Vander Stoep · 3 months ago emu-34-2-dev main main-16k master
  2. b91ba54 Upgrade pdl-runtime to 0.2.3 by Jeff Vander Stoep · 3 months ago emu-34-3-release
  3. d7cdc35 Migrate to cargo_embargo. am: 590d9e906d am: 92b814bd34 am: f2aa97cf4f by Andrew Walbran · 6 months ago
  4. 539be0c Migrate to cargo_embargo. am: 590d9e906d am: e1405e9915 am: 60adb2ea6c by Andrew Walbran · 6 months ago
  5. f2aa97c Migrate to cargo_embargo. am: 590d9e906d am: 92b814bd34 by Andrew Walbran · 6 months ago

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