8 releases

0.3.2 Nov 18, 2024
0.3.1 Jul 15, 2024
0.3.0 May 24, 2024
0.2.3 Nov 13, 2023
0.1.7 Aug 31, 2023

#261 in Parser tooling

Download history 284/week @ 2024-08-26 353/week @ 2024-09-02 465/week @ 2024-09-09 140/week @ 2024-09-16 160/week @ 2024-09-23 422/week @ 2024-09-30 74/week @ 2024-10-07 75/week @ 2024-10-14 108/week @ 2024-10-21 130/week @ 2024-10-28 97/week @ 2024-11-04 232/week @ 2024-11-11 368/week @ 2024-11-18 90/week @ 2024-11-25 114/week @ 2024-12-02 97/week @ 2024-12-09

700 downloads per month
Used in bumble

Apache-2.0

655KB
14K SLoC

Rust 11K SLoC // 0.1% comments Python 3K SLoC // 0.2% comments Pest 108 SLoC

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

Dependencies

~4–11MB
~131K SLoC