12 releases

0.2.3 Nov 13, 2023
0.2.2 Oct 30, 2023
0.2.0 Sep 29, 2023
0.1.7 Aug 31, 2023
0.1.1 May 24, 2023

#283 in Parser implementations

Download history 360/week @ 2023-12-10 426/week @ 2023-12-17 326/week @ 2023-12-24 127/week @ 2023-12-31 208/week @ 2024-01-07 240/week @ 2024-01-14 526/week @ 2024-01-21 480/week @ 2024-01-28 117/week @ 2024-02-04 84/week @ 2024-02-18 98/week @ 2024-02-25 247/week @ 2024-03-03 299/week @ 2024-03-10 134/week @ 2024-03-17 182/week @ 2024-03-24

865 downloads per month
Used in 3 crates (2 directly)

Apache-2.0

585KB
12K SLoC

Rust 9K SLoC // 0.1% comments Python 3K SLoC // 0.2% comments Pest 109 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

~3–4.5MB
~84K SLoC