Struct crc::Algorithm

source ·
pub struct Algorithm<W>
where W: Width,
{ pub width: u8, pub poly: W, pub init: W, pub refin: bool, pub refout: bool, pub xorout: W, pub check: W, pub residue: W, }
Expand description

This struct describes a CRC algorithm using the fields specified by the Catalogue of parametrised CRC algorithms.

Fields§

§width: u8

The number of bit cells in the linear feedback shift register; the degree of the generator polynomial, minus one.

§poly: W

The generator polynomial that sets the feedback tap positions of the shift register. The least significant bit corresponds to the inward end of the shift register, and is always set. The highest-order term is omitted.

§init: W

The settings of the bit cells at the start of each calculation, before reading the first message bit. The least significant bit corresponds to the inward end of the shift register.

§refin: bool

If equal to false, specifies that the characters of the message are read bit-by-bit, most significant bit (MSB) first; if equal to true, the characters are read bit-by-bit, least significant bit (LSB) first. Each sampled message bit is then XORed with the bit being simultaneously shifted out of the register at the most significant end, and the result is passed to the feedback taps.

§refout: bool

If equal to false, specifies that the contents of the register after reading the last message bit are unreflected before presentation; if equal to true, it specifies that they are reflected, character-by-character, before presentation. For the purpose of this definition, the reflection is performed by swapping the content of each cell with that of the cell an equal distance from the opposite end of the register; the characters of the CRC are then true images of parts of the reflected register, the character containing the original MSB always appearing first.

§xorout: W

The XOR value applied to the contents of the register after the last message bit has been read and after the optional reflection. It has the same endianness as the CRC such that its true image appears in the characters of the CRC.

§check: W

The contents of the register after initialising, reading the UTF-8 string "123456789" (as 8-bit characters), optionally reflecting, and applying the final XOR.

§residue: W

The contents of the register after initialising, reading an error-free codeword and optionally reflecting the register (if refout=true), but not applying the final XOR. This is mathematically equivalent to initialising the register with the xorout parameter, reflecting it as described (if refout=true), reading as many zero bits as there are cells in the register, and reflecting the result (if refin=true). The residue of a crossed-endian model is calculated assuming that the characters of the received CRC are specially reflected before submitting the codeword.

Auto Trait Implementations§

§

impl<W> Freeze for Algorithm<W>
where W: 'static + Freeze,

§

impl<W> RefUnwindSafe for Algorithm<W>
where W: 'static + RefUnwindSafe,

§

impl<W> Send for Algorithm<W>
where W: 'static + Send,

§

impl<W> Sync for Algorithm<W>
where W: 'static + Sync,

§

impl<W> Unpin for Algorithm<W>
where W: 'static + Unpin,

§

impl<W> UnwindSafe for Algorithm<W>
where W: 'static + UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.