Bug: 283153347

Clone this repo:
  1. fe8259d Add external/rust/pica to the default visibility list am: 2ce036f7b4 am: e4f612e976 am: 6dc80e3f4f by Henri Chataing · 5 months ago emu-34-2-dev main main-16k master
  2. 6dc80e3 Add external/rust/pica to the default visibility list am: 2ce036f7b4 am: e4f612e976 by Henri Chataing · 5 months ago
  3. e4f612e Add external/rust/pica to the default visibility list am: 2ce036f7b4 by Henri Chataing · 5 months ago
  4. 2ce036f Add external/rust/pica to the default visibility list by Henri Chataing · 5 months ago emu-34-3-release
  5. e5f3986 Merge "Migrate to cargo_embargo." into main am: 6d93ae5605 am: 9f0d5f95b0 am: fe2c5a9ad2 by Treehugger Robot · 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