technocreatives / dbc-codegen

Generate Rust structs for messages from a dbc (CAN bus definition) file.
Apache License 2.0
43 stars 22 forks source link

Added an id method to all message structs #71

Open JoNil opened 1 month ago

projectgus commented 1 month ago

What's the value of this over accessing the public constant?

I can't speak for @JoNil, but what I was hoping to work towards is defining a trait over all messages that lets you access message_id and raw. With a goal to writing code in my project like a send<impl that_trait>(&msg) function that sends an arbitrary message struct to a CAN controller, for example.

killercup commented 1 month ago

That’s a good idea, I’d merge in this trait :) this will add a teeny tiny bit of a runtime crate though which we’d need to add as a dependency. (Reminds me of #35)

On Tue, 14 May 2024 at 01:09, Angus Gratton @.***> wrote:

What's the value of this over accessing the public constant?

I can't speak for @JoNil https://github.com/JoNil, but what I was hoping to work towards is defining a trait over all messages that lets you access message_id and raw. With a goal to building things like a send<impl that_trait>(&msg) function that sends an arbitrary message struct to a CAN controller, for example.

— Reply to this email directly, view it on GitHub https://github.com/technocreatives/dbc-codegen/pull/71#issuecomment-2108956039, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAE4XZ4XRNXABIMXDIHHQTZCFB4NAVCNFSM6AAAAABHM5RWXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBYHE2TMMBTHE . You are receiving this because you commented.Message ID: @.***>