Snap for 11049560 from 5ad493ce1a6d335af300f7a2b6369b0a9de317f4 to mainline-art-release

Change-Id: If668a04eb1bc4dcffc4410c641dfaac83a94f0f8
tree: 897836674c74faac90707276de61c91a3c2e8c6b
  1. doc/
  2. examples/
  3. patches/
  4. scripts/
  5. src/
  6. tests/
  7. .cargo_vcs_info.json
  8. .gitignore
  9. Android.bp
  10. Cargo.toml
  11. Cargo.toml.orig
  12. cargo2android.json
  13. cargo2android_toplevel.bp
  14. CONTRIBUTING.md
  15. LICENSE
  16. METADATA
  17. MODULE_LICENSE_APACHE2
  18. OWNERS
  19. README.md
  20. rustfmt.toml
README.md

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
  • Nested packets
  • Conditional packet derivation
  • Custom field definitions

Similar projects