pub struct CrcParams {
pub algorithm: CrcAlgorithm,
pub name: &'static str,
pub width: u8,
pub poly: u64,
pub init: u64,
pub init_algorithm: u64,
pub refin: bool,
pub refout: bool,
pub xorout: u64,
pub check: u64,
pub keys: CrcKeysStorage,
}Expand description
Parameters for CRC computation, including polynomial, initial value, and other settings.
Fields§
§algorithm: CrcAlgorithm§name: &'static str§width: u8§poly: u64§init: u64§init_algorithm: u64The init value in “algorithm form” for the SIMD implementation.
For most CRC variants, this equals init. However, for reflected CRC-16 variants
with non-symmetric init values (e.g., CRC-16/ISO-IEC-14443-3-A with init=0xC6C6),
this stores the bit-reversed init value. This avoids runtime bit-reversal on every
update() call, which would otherwise be needed because the SIMD algorithm operates
on data in a different bit order than the catalog specification.
Examples:
- CRC-16/IBM-SDLC: init=0xFFFF, init_algorithm=0xFFFF (symmetric)
- CRC-16/ISO-IEC-14443-3-A: init=0xC6C6, init_algorithm=0x6363 (0xC6C6.reverse_bits())
refin: bool§refout: bool§xorout: u64§check: u64§keys: CrcKeysStorageImplementations§
Source§impl CrcParams
impl CrcParams
Sourcepub fn new(
name: &'static str,
width: u8,
poly: u64,
init: u64,
reflected: bool,
xorout: u64,
check: u64,
) -> Self
pub fn new( name: &'static str, width: u8, poly: u64, init: u64, reflected: bool, xorout: u64, check: u64, ) -> Self
Creates custom CRC parameters for a given set of Rocksoft CRC parameters.
Uses an internal cache to avoid regenerating folding keys for identical parameter sets. The first call with a given set of parameters will generate and cache the keys, while subsequent calls with the same parameters will use the cached keys for optimal performance.
Does not support mis-matched refin/refout parameters, so both must be true or both false.
Rocksoft parameters for lots of variants: https://reveng.sourceforge.io/crc-catalogue/all.htm
Sourcepub fn get_key(&self, index: usize) -> u64
pub fn get_key(&self, index: usize) -> u64
Gets a key at the specified index, returning 0 if out of bounds. This provides safe access regardless of internal key storage format.
Sourcepub fn get_key_checked(&self, index: usize) -> Option<u64>
pub fn get_key_checked(&self, index: usize) -> Option<u64>
Gets a key at the specified index, returning None if out of bounds. This provides optional key access for cases where bounds checking is needed.