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

Impl std::error::Error for CanError #36

Closed andresv closed 3 years ago

andresv commented 3 years ago

Implements std::error::Error for CanError.

This allows simple use of anyhow for error handling.

use anyhow::Result;

fn run() -> Result<()> {
   let mut socket_rx = CANSocket::open("vcan0")?
   ...
   let m = messages::SteeringLevers::try_from(p.as_slice())?;
   ...
}
andresv commented 3 years ago

Okay, should have run tests first on my machine. Hmm, so it should be opt in feature then.

killercup commented 3 years ago

nice! yeah, please make it an new feature. maybe call it "use-std" or something like that? not sure what is common

marcelbuesing commented 3 years ago

nice! yeah, please make it an new feature. maybe call it "use-std" or something like that? not sure what is common

I think I have seen "std " e.g. in bitvec.