[][src]Macro embedded_crc_macros::crc8_hasher

macro_rules! crc8_hasher {
    ($struct_name:ident, $poly:expr, $initial_value:expr, $doc:expr) => { ... };
}

Define public structure implementing the CRC-8 algorithm for the given polynomial and initial value as a core::hash::Hasher trait implementation.

A struct name and some documentation for it must be provided. For example:

use core::hash::Hasher;
use embedded_crc_macros::crc8_hasher;

crc8_hasher!(SmbusPec, 7 /* x^8+x^2+x+1 */, 0, "SMBus Packet Error Code");

let mut hasher = SmbusPec::new();
hasher.write(&[0xAB, 0xCD]);
let pec = hasher.finish();

println!("PEC: {}", pec);