Skip to main content

Crc16Algorithm

Struct Crc16Algorithm 

Source
pub struct Crc16Algorithm {
    pub poly: u16,
    pub init: u16,
    pub refin: bool,
    pub refout: bool,
    pub xorout: u16,
    pub check: u16,
    /* private fields */
}
Expand description

A CRC-16 variant (16-bit generator, Rocksoft parameters).

Build a custom variant with new; the named pub const definitions in this module cover the usual sets. Not cryptographic — see the module docs.

Fields§

§poly: u16

Generator polynomial (Rocksoft normal form, MSB-first).

§init: u16

Initial register value.

§refin: bool

Reflect input bytes (LSB-first) if true.

§refout: bool

Reflect the final register if true.

§xorout: u16

Value XORed into the final register.

§check: u16

CRC of b"123456789" — the self-check value (RevEng check).

Implementations§

Source§

impl Crc16Algorithm

Source

pub const fn new( poly: u16, init: u16, refin: bool, refout: bool, xorout: u16, check: u16, ) -> Self

Define a CRC variant from its Rocksoft parameters. const, so the 256-entry table is generated at compile time.

  • poly / init / refin / refout / xorout: model params.
  • check: the expected CRC of b"123456789" (asserted in tests).

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

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.