Merge "Migrate to cargo_embargo." into main am: 6d93ae5605

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/pdl-compiler/+/2828248

Change-Id: Ia56b5c60b186d487ea4eb37e38a5a6ffbb62c169
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: d261c5021cf1151e37b78b4c190a16037bd0575e
  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_toplevel.bp
  13. cargo_embargo.json
  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
  • Optional fields
  • Nested packets
  • Conditional packet derivation
  • Custom field definitions

Similar projects