CrcParams

Struct CrcParams 

Source
pub struct CrcParams {
    pub algorithm: CrcAlgorithm,
    pub name: &'static str,
    pub width: u8,
    pub poly: u64,
    pub init: 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§refin: bool§refout: bool§xorout: u64§check: u64§keys: CrcKeysStorage

Implementations§

Source§

impl CrcParams

Source

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

Source

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.

Source

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.

Source

pub fn key_count(self) -> usize

Returns the number of keys available in this CrcParams instance.

Trait Implementations§

Source§

impl Clone for CrcParams

Source§

fn clone(&self) -> CrcParams

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CrcParams

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for CrcParams

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.