Struct crc_any::CRCu32

source ·
pub struct CRCu32 { /* private fields */ }
Expand description

This struct can help you compute a CRC-32 (or CRC-x where x is equal or less than 32) value.

Implementations§

source§

impl CRCu32

source

pub fn create_crc( poly: u32, bits: u8, initial: u32, final_xor: u32, reflect: bool ) -> CRCu32

Create a CRCu32 instance by providing the length of bits, expression, reflection, an initial value and a final xor value.

source

pub fn digest<T: ?Sized + AsRef<[u8]>>(&mut self, data: &T)

Digest some data.

source

pub fn reset(&mut self)

Reset the sum.

source

pub fn get_crc(&self) -> u32

Get the current CRC value (it always returns a u32 value). You can continue calling digest method even after getting a CRC value.

source§

impl CRCu32

source

pub fn get_crc_vec_le(&mut self) -> Vec<u8>

Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling digest method even after getting a CRC value.

source

pub fn get_crc_vec_be(&mut self) -> Vec<u8>

Get the current CRC value (it always returns a vec instance with a length corresponding to the CRC bits). You can continue calling digest method even after getting a CRC value.

source§

impl CRCu32

source

pub fn crc17can() -> CRCu32

CheckPolyInitRefXorOut
0x04F030x1685B0x00000false0x00000
let mut crc = CRCu32::crc17can();
crc.digest(b"123456789");
assert_eq!("0x04F03", &crc.to_string());
source

pub fn crc21can() -> CRCu32

CheckPolyInitRefXorOut
0x0ED8410x1028990x000000false0x000000
let mut crc = CRCu32::crc21can();
crc.digest(b"123456789");
assert_eq!("0x0ED841", &crc.to_string());
source

pub fn crc24() -> CRCu32

CheckPolyInitRefXorOut
0x21CF020x864CFB0xB704CEfalse0x000000
let mut crc = CRCu32::crc24();
crc.digest(b"123456789");
assert_eq!("0x21CF02", &crc.to_string());
source

pub fn crc24ble() -> CRCu32

CheckPolyInitRefXorOut
0xC25A560x00065B (rev: 0xDA6000)0x555555true0x000000
let mut crc = CRCu32::crc24ble();
crc.digest(b"123456789");
assert_eq!("0xC25A56", &crc.to_string());
source

pub fn crc24flexray_a() -> CRCu32

CheckPolyInitRefXorOut
0x7979BD0x5D6DCB0xFEDCBAfalse0x000000
let mut crc = CRCu32::crc24flexray_a();
crc.digest(b"123456789");
assert_eq!("0x7979BD", &crc.to_string());
source

pub fn crc24flexray_b() -> CRCu32

CheckPolyInitRefXorOut
0x1F23B80x5D6DCB0xABCDEFfalse0x000000
let mut crc = CRCu32::crc24flexray_b();
crc.digest(b"123456789");
assert_eq!("0x1F23B8", &crc.to_string());
source

pub fn crc24lte_a() -> CRCu32

CheckPolyInitRefXorOut
0xCDE7030x864CFB0x000000false0x000000
let mut crc = CRCu32::crc24lte_a();
crc.digest(b"123456789");
assert_eq!("0xCDE703", &crc.to_string());
source

pub fn crc24lte_b() -> CRCu32

CheckPolyInitRefXorOut
0x23EF520x8000630x000000false0x000000
let mut crc = CRCu32::crc24lte_b();
crc.digest(b"123456789");
assert_eq!("0x23EF52", &crc.to_string());
source

pub fn crc24os9() -> CRCu32

CheckPolyInitRefXorOut
0x200FA50x8000630xFFFFFFfalse0xFFFFFF
let mut crc = CRCu32::crc24os9();
crc.digest(b"123456789");
assert_eq!("0x200FA5", &crc.to_string());
source

pub fn crc30cdma() -> CRCu32

CheckPolyInitRefXorOut
0x04C34ABF0x2030B9C70x3FFFFFFFfalse0x3FFFFFFF
let mut crc = CRCu32::crc30cdma();
crc.digest(b"123456789");
assert_eq!("0x04C34ABF", &crc.to_string());
source

pub fn crc32() -> CRCu32

CheckPolyInitRefXorOut
0xCBF439260x04C11DB7 (rev: 0xEDB88320)0xFFFFFFFFtrue0xFFFFFFFF
let mut crc = CRCu32::crc32();
crc.digest(b"123456789");
assert_eq!("0xCBF43926", &crc.to_string());
source

pub fn crc32mhash() -> CRCu32

CheckPolyInitRefXorOut
0x181989FC0x04C11DB70xFFFFFFFFfalse0xFFFFFFFF

Output will be reversed by bytes.

let mut crc = CRCu32::crc32mhash();
crc.digest(b"123456789");
assert_eq!("0x181989FC", &crc.to_string());
source

pub fn crc32bzip2() -> CRCu32

CheckPolyInitRefXorOut
0xFC8919180x04C11DB70xFFFFFFFFfalse0xFFFFFFFF
let mut crc = CRCu32::crc32bzip2();
crc.digest(b"123456789");
assert_eq!("0xFC891918", &crc.to_string());
source

pub fn crc32c() -> CRCu32

CheckPolyInitRefXorOut
0xE30692830x1EDC6F41 (rev: 0x82F63B78)0xFFFFFFFFtrue0xFFFFFFFF
let mut crc = CRCu32::crc32c();
crc.digest(b"123456789");
assert_eq!("0xE3069283", &crc.to_string());
source

pub fn crc32d() -> CRCu32

CheckPolyInitRefXorOut
0x873155760xA833982B (rev: 0xD419CC15)0xFFFFFFFFtrue0xFFFFFFFF
let mut crc = CRCu32::crc32d();
crc.digest(b"123456789");
assert_eq!("0x87315576", &crc.to_string());
source

pub fn crc32mpeg2() -> CRCu32

CheckPolyInitRefXorOut
0x0376E6E70x04C11DB70xFFFFFFFFfalse0x00000000
let mut crc = CRCu32::crc32mpeg2();
crc.digest(b"123456789");
assert_eq!("0x0376E6E7", &crc.to_string());
source

pub fn crc32posix() -> CRCu32

CheckPolyInitRefXorOut
0x765E76800x04C11DB70x00000000false0xFFFFFFFF
let mut crc = CRCu32::crc32posix();
crc.digest(b"123456789");
assert_eq!("0x765E7680", &crc.to_string());
source

pub fn crc32q() -> CRCu32

CheckPolyInitRefXorOut
0x3010BF7F0x814141AB0x00000000false0x00000000
let mut crc = CRCu32::crc32q();
crc.digest(b"123456789");
assert_eq!("0x3010BF7F", &crc.to_string());
source

pub fn crc32jamcrc() -> CRCu32

CheckPolyInitRefXorOut
0x340BC6D90x04C11DB7 (rev: 0xEDB88320)0xFFFFFFFFtrue0x00000000
let mut crc = CRCu32::crc32jamcrc();
crc.digest(b"123456789");
assert_eq!("0x340BC6D9", &crc.to_string());
source

pub fn crc32xfer() -> CRCu32

CheckPolyInitRefXorOut
0xBD0BE3380x000000AF0x00000000false0x00000000
let mut crc = CRCu32::crc32xfer();
crc.digest(b"123456789");
assert_eq!("0xBD0BE338", &crc.to_string());

Trait Implementations§

source§

impl Debug for CRCu32

source§

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

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

impl Display for CRCu32

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for CRCu32

§

impl RefUnwindSafe for CRCu32

§

impl Send for CRCu32

§

impl Sync for CRCu32

§

impl Unpin for CRCu32

§

impl UnwindSafe for CRCu32

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.