14 releases

0.3.1 Jul 15, 2024
0.2.3 Nov 13, 2023
0.1.5 Jul 26, 2023

#243 in Parser implementations

Download history 96/week @ 2024-07-21 246/week @ 2024-07-28 259/week @ 2024-08-04 260/week @ 2024-08-11 305/week @ 2024-08-18 295/week @ 2024-08-25 411/week @ 2024-09-01 476/week @ 2024-09-08 148/week @ 2024-09-15 185/week @ 2024-09-22 491/week @ 2024-09-29 124/week @ 2024-10-06 112/week @ 2024-10-13 120/week @ 2024-10-20 137/week @ 2024-10-27 110/week @ 2024-11-03

488 downloads per month
Used in 4 crates (3 directly)

Apache-2.0

725KB
16K SLoC

Rust 12K 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

~4–12MB
~136K SLoC