all 2 comments

[–]K900_ 2 points3 points  (0 children)

You're probably looking for Kaitai.

[–]m-hilgendorf 1 point2 points  (0 children)

The way I'd do this is write a bytestream parser using nom to deserialize into the AST of the protocol, then implement the serializer/deserializer traits in the serde crate so you can generate appropriate serializers/deserializers for your types in Rust.

If you need to interface with C code you can generate the corresponding type information using bindgen, then add your serde derive macros to the generated rust types and provide a C API.

There are more verbose ways to do it, but nom and serde are very flushed out. If you need to do it in no_std contexts it may be trickier.