dbc-codegen icon indicating copy to clipboard operation
dbc-codegen copied to clipboard

Create separate crate for helper types and external dependencies

Open scootermon opened this issue 1 year ago • 2 comments

The main issue I want to address is that the generated code currently contains the CanError enum. I have multiple DBC files for different can buses that I would like to abstract in a single crate, but having multiple equal but distinct CanError types makes this really annoying.

To solve this I think it would be good to introduce a separate runtime crate. This crate can then hold common types and also re-export the additional dependencies used by the extra code. The latter can be done through a hidden module like:

#[doc(hidden)]
mod __priv {
  pub use bitvec;
  // [...]
}

I'm happy to work on an initial implementation if we're happy with this approach.

scootermon avatar Aug 27 '24 18:08 scootermon

What do you think of #35? I'd be happy to merge some big refactors if you can motivate them :)

killercup avatar Aug 28 '24 13:08 killercup

#35 is exactly the use case I wanted to use this crate for initially. I have a repository of dbc files and I wanted to just iterate over all of them, generate a crate for each one, and publish them to an internal registry.

scootermon avatar Aug 28 '24 15:08 scootermon