Import platform/external/rust/crates/pdl-compiler

Import version 0.1.1 of crate pdl-compiler
Cargo.lock is removed to make sure the emulator
build is working with corrosion.

Bug: 283153347
Test: m
Change-Id: I6d0d099c1548762b608e933b148f5b2f5261f5e2
143 files changed
tree: 51b36d886865f420c52e5d496c53f1ce17624624
  1. doc/
  2. scripts/
  3. src/
  4. tests/
  5. Android.bp
  6. Cargo.toml
  7. Cargo.toml.orig
  8. cargo2android.json
  9. cargo2android_toplevel.bp
  10. CONTRIBUTING.md
  11. LICENSE
  12. METADATA
  13. MODULE_LICENSE_APACHE2
  14. OWNERS
  15. README.md
  16. 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