Expand description
Module providing utility traits for decoding CAN-bus data.
The module provides three traits: TryDecode, DefaultDecode, and Decode. try_decode models the possibility of the decoding to fail. default_decode returns a default value if the decoding fails. Finally, decode panics if the internal decoding fails. Otherwise, it returns the decoded value.
§Example
use cantools::data::CANRead;
use cantools::signals::Bit;
use cantools::decode::{TryDecode, DefaultDecode, Decode};
let bit = Bit::new(20);
let mut data = [1u8, 2u8, 3u8, 4u8];
let result_1 = bit.try_decode(&data);
let result_2 = bit.default_decode(&data);
let result_3 = bit.decode(&data);
Enums§
- Decode
Error - Type representing possible decoding errors.
Traits§
- Decode
- A trait modeling the not failable decoding of data.
- Default
Decode - A trait modeling the failable decoding of data.
- TryDecode
- A trait modeling the failable decoding of data.