7 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.2.0 Sep 29, 2023

#469 in Encoding

Download history 178/week @ 2024-08-16 383/week @ 2024-08-23 282/week @ 2024-08-30 549/week @ 2024-09-06 183/week @ 2024-09-13 106/week @ 2024-09-20 490/week @ 2024-09-27 131/week @ 2024-10-04 75/week @ 2024-10-11 133/week @ 2024-10-18 142/week @ 2024-10-25 115/week @ 2024-11-01 167/week @ 2024-11-08 410/week @ 2024-11-15 146/week @ 2024-11-22 166/week @ 2024-11-29

904 downloads per month
Used in 3 crates

Apache-2.0

10KB
89 lines

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

~0.4–0.9MB
~19K SLoC