Struct Algorithm

Source
pub struct Algorithm<T> {
    pub endian: Endian,
    pub poly: T,
    pub init: T,
    pub refin: bool,
    pub refout: bool,
    pub xorout: T,
    pub residue: T,
}
Expand description

CRC algorithm.

Fields§

§endian: Endian§poly: T§init: T§refin: bool§refout: bool§xorout: T§residue: T

Implementations§

Source§

impl Algorithm<u16>

Source

pub const fn new( endian: Endian, poly: u16, init: u16, refin: bool, refout: bool, xorout: u16, ) -> (Self, u16, [u16; 256])

Source

pub const fn to_endian_bytes(n: u16, endian: Endian) -> [u8; 2]

Source

pub const fn initialize(init: u16, refin: bool) -> u16

Initialize value.

Source

pub const fn optional_reflection(refin: bool, refout: bool, value: u16) -> u16

Optional reflection.

Source

pub const fn finalize(refin: bool, refout: bool, xorout: u16, value: u16) -> u16

Finalize value. Change value to checksum.

Source

pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u16, value: u16, ) -> [u8; 2]

Finalize to endian bytes.

Source

pub const fn calc_byte_with_reciprocal_poly( reciprocal_poly: u16, refin: bool, byte: u8, ) -> u16

Caluculate byte with reciprocal polynomial.

Source

pub const fn create_table(poly: u16, refin: bool) -> [u16; 256]

Create table.

Source

pub const fn calc_bytes_with_values( refin: bool, value: u16, bytes: &[u8], table: &[u16; 256], ) -> u16

Caluculate bytes with values.

Source§

impl Algorithm<u32>

Source

pub const fn new( endian: Endian, poly: u32, init: u32, refin: bool, refout: bool, xorout: u32, ) -> (Self, u32, [u32; 256])

Source

pub const fn to_endian_bytes(n: u32, endian: Endian) -> [u8; 4]

Source

pub const fn initialize(init: u32, refin: bool) -> u32

Initialize value.

Source

pub const fn optional_reflection(refin: bool, refout: bool, value: u32) -> u32

Optional reflection.

Source

pub const fn finalize(refin: bool, refout: bool, xorout: u32, value: u32) -> u32

Finalize value. Change value to checksum.

Source

pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u32, value: u32, ) -> [u8; 4]

Finalize to endian bytes.

Source

pub const fn calc_byte_with_reciprocal_poly( reciprocal_poly: u32, refin: bool, byte: u8, ) -> u32

Caluculate byte with reciprocal polynomial.

Source

pub const fn create_table(poly: u32, refin: bool) -> [u32; 256]

Create table.

Source

pub const fn calc_bytes_with_values( refin: bool, value: u32, bytes: &[u8], table: &[u32; 256], ) -> u32

Caluculate bytes with values.

Source§

impl Algorithm<u64>

Source

pub const fn new( endian: Endian, poly: u64, init: u64, refin: bool, refout: bool, xorout: u64, ) -> (Self, u64, [u64; 256])

Source

pub const fn to_endian_bytes(n: u64, endian: Endian) -> [u8; 8]

Source

pub const fn initialize(init: u64, refin: bool) -> u64

Initialize value.

Source

pub const fn optional_reflection(refin: bool, refout: bool, value: u64) -> u64

Optional reflection.

Source

pub const fn finalize(refin: bool, refout: bool, xorout: u64, value: u64) -> u64

Finalize value. Change value to checksum.

Source

pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u64, value: u64, ) -> [u8; 8]

Finalize to endian bytes.

Source

pub const fn calc_byte_with_reciprocal_poly( reciprocal_poly: u64, refin: bool, byte: u8, ) -> u64

Caluculate byte with reciprocal polynomial.

Source

pub const fn create_table(poly: u64, refin: bool) -> [u64; 256]

Create table.

Source

pub const fn calc_bytes_with_values( refin: bool, value: u64, bytes: &[u8], table: &[u64; 256], ) -> u64

Caluculate bytes with values.

Source§

impl Algorithm<u128>

Source

pub const fn new( endian: Endian, poly: u128, init: u128, refin: bool, refout: bool, xorout: u128, ) -> (Self, u128, [u128; 256])

Source

pub const fn to_endian_bytes(n: u128, endian: Endian) -> [u8; 16]

Source

pub const fn initialize(init: u128, refin: bool) -> u128

Initialize value.

Source

pub const fn optional_reflection(refin: bool, refout: bool, value: u128) -> u128

Optional reflection.

Source

pub const fn finalize( refin: bool, refout: bool, xorout: u128, value: u128, ) -> u128

Finalize value. Change value to checksum.

Source

pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u128, value: u128, ) -> [u8; 16]

Finalize to endian bytes.

Source

pub const fn calc_byte_with_reciprocal_poly( reciprocal_poly: u128, refin: bool, byte: u8, ) -> u128

Caluculate byte with reciprocal polynomial.

Source

pub const fn create_table(poly: u128, refin: bool) -> [u128; 256]

Create table.

Source

pub const fn calc_bytes_with_values( refin: bool, value: u128, bytes: &[u8], table: &[u128; 256], ) -> u128

Caluculate bytes with values.

Trait Implementations§

Source§

impl<T: Clone> Clone for Algorithm<T>

Source§

fn clone(&self) -> Algorithm<T>

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<T: Debug> Debug for Algorithm<T>

Source§

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

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

impl<T: Hash> Hash for Algorithm<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: PartialEq> PartialEq for Algorithm<T>

Source§

fn eq(&self, other: &Algorithm<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Copy> Copy for Algorithm<T>

Source§

impl<T: Eq> Eq for Algorithm<T>

Source§

impl<T> StructuralPartialEq for Algorithm<T>

Auto Trait Implementations§

§

impl<T> Freeze for Algorithm<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Algorithm<T>
where T: RefUnwindSafe,

§

impl<T> Send for Algorithm<T>
where T: Send,

§

impl<T> Sync for Algorithm<T>
where T: Sync,

§

impl<T> Unpin for Algorithm<T>
where T: Unpin,

§

impl<T> UnwindSafe for Algorithm<T>
where T: 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> 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, 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.