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>
impl Algorithm<u16>
pub const fn new( endian: Endian, poly: u16, init: u16, refin: bool, refout: bool, xorout: u16, ) -> (Self, u16, [u16; 256])
pub const fn to_endian_bytes(n: u16, endian: Endian) -> [u8; 2]
Sourcepub const fn initialize(init: u16, refin: bool) -> u16
pub const fn initialize(init: u16, refin: bool) -> u16
Initialize value.
Sourcepub const fn optional_reflection(refin: bool, refout: bool, value: u16) -> u16
pub const fn optional_reflection(refin: bool, refout: bool, value: u16) -> u16
Optional reflection.
Sourcepub const fn finalize(refin: bool, refout: bool, xorout: u16, value: u16) -> u16
pub const fn finalize(refin: bool, refout: bool, xorout: u16, value: u16) -> u16
Finalize value. Change value to checksum.
Sourcepub const fn finalize_to_endian_bytes(
endian: Endian,
refin: bool,
refout: bool,
xorout: u16,
value: u16,
) -> [u8; 2]
pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u16, value: u16, ) -> [u8; 2]
Finalize to endian bytes.
Source§impl Algorithm<u32>
impl Algorithm<u32>
pub const fn new( endian: Endian, poly: u32, init: u32, refin: bool, refout: bool, xorout: u32, ) -> (Self, u32, [u32; 256])
pub const fn to_endian_bytes(n: u32, endian: Endian) -> [u8; 4]
Sourcepub const fn initialize(init: u32, refin: bool) -> u32
pub const fn initialize(init: u32, refin: bool) -> u32
Initialize value.
Sourcepub const fn optional_reflection(refin: bool, refout: bool, value: u32) -> u32
pub const fn optional_reflection(refin: bool, refout: bool, value: u32) -> u32
Optional reflection.
Sourcepub const fn finalize(refin: bool, refout: bool, xorout: u32, value: u32) -> u32
pub const fn finalize(refin: bool, refout: bool, xorout: u32, value: u32) -> u32
Finalize value. Change value to checksum.
Sourcepub const fn finalize_to_endian_bytes(
endian: Endian,
refin: bool,
refout: bool,
xorout: u32,
value: u32,
) -> [u8; 4]
pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u32, value: u32, ) -> [u8; 4]
Finalize to endian bytes.
Source§impl Algorithm<u64>
impl Algorithm<u64>
pub const fn new( endian: Endian, poly: u64, init: u64, refin: bool, refout: bool, xorout: u64, ) -> (Self, u64, [u64; 256])
pub const fn to_endian_bytes(n: u64, endian: Endian) -> [u8; 8]
Sourcepub const fn initialize(init: u64, refin: bool) -> u64
pub const fn initialize(init: u64, refin: bool) -> u64
Initialize value.
Sourcepub const fn optional_reflection(refin: bool, refout: bool, value: u64) -> u64
pub const fn optional_reflection(refin: bool, refout: bool, value: u64) -> u64
Optional reflection.
Sourcepub const fn finalize(refin: bool, refout: bool, xorout: u64, value: u64) -> u64
pub const fn finalize(refin: bool, refout: bool, xorout: u64, value: u64) -> u64
Finalize value. Change value to checksum.
Sourcepub const fn finalize_to_endian_bytes(
endian: Endian,
refin: bool,
refout: bool,
xorout: u64,
value: u64,
) -> [u8; 8]
pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u64, value: u64, ) -> [u8; 8]
Finalize to endian bytes.
Source§impl Algorithm<u128>
impl Algorithm<u128>
pub const fn new( endian: Endian, poly: u128, init: u128, refin: bool, refout: bool, xorout: u128, ) -> (Self, u128, [u128; 256])
pub const fn to_endian_bytes(n: u128, endian: Endian) -> [u8; 16]
Sourcepub const fn initialize(init: u128, refin: bool) -> u128
pub const fn initialize(init: u128, refin: bool) -> u128
Initialize value.
Sourcepub const fn optional_reflection(refin: bool, refout: bool, value: u128) -> u128
pub const fn optional_reflection(refin: bool, refout: bool, value: u128) -> u128
Optional reflection.
Sourcepub const fn finalize(
refin: bool,
refout: bool,
xorout: u128,
value: u128,
) -> u128
pub const fn finalize( refin: bool, refout: bool, xorout: u128, value: u128, ) -> u128
Finalize value. Change value to checksum.
Sourcepub const fn finalize_to_endian_bytes(
endian: Endian,
refin: bool,
refout: bool,
xorout: u128,
value: u128,
) -> [u8; 16]
pub const fn finalize_to_endian_bytes( endian: Endian, refin: bool, refout: bool, xorout: u128, value: u128, ) -> [u8; 16]
Finalize to endian bytes.
Trait Implementations§
impl<T: Copy> Copy for Algorithm<T>
impl<T: Eq> Eq for Algorithm<T>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more