cantools icon indicating copy to clipboard operation
cantools copied to clipboard

How to consider supporting Rust

Open lcwxz1989 opened this issue 3 months ago • 3 comments

rust is a popular language than before, how to consider supporting Rust

lcwxz1989 avatar Sep 22 '25 09:09 lcwxz1989

If you want to try adding rust support (I assume for code generation), you can have a look at c_source.py. You would fork cantools, copy c_source.py, name it rust_source.py and implement your rust generator there in a similar fashion.

For integration, you also need to add a rust subparser ultimately.

When that is done you can write tests to make sure your generator code is covered and remains in good working order.

Lastly, you issue a pull request to this project.

It is a neat project to step into this.

juleq avatar Sep 22 '25 11:09 juleq

For DBC files, there’s already an existing project - dbc-codegen - written entirely in Rust. The code generation can be nicely integrated into build.rs. Just not sure what features it misses compared to cantools.

trnila avatar Sep 22 '25 18:09 trnila

Several of us just started Image OxiBUS github org to implement Rust low level comm libraries. It's a community-driven volunteer open source initiative. Several projects already onboarded, and I am working to onboard more:

In progress

  • can-dbc - well know parser with good following

On-boarder

  • automotive_diag by @nyurik (me) - onboarded - definitions for UDS/KWP2000/OBD-II/DoIP/...
  • dbc-data by @tegimeki - onboarded - simple codegen
  • MDGSF/rdbc - onboarded - a thorough DBC parser - merging it with can-dbc might prove a very good path forward.

I would love to join forces with dbc-codegen and possibly others so that std, no-std, and perhaps other approaches could be generated and experimented with. Everyone with good github history is welcome to join :)

nyurik avatar Oct 02 '25 07:10 nyurik