Struct crc_any::CRCu8

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

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

Implementations§

source§

impl CRCu8

source

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

Create a CRCu8 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) -> u8

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

source§

impl CRCu8

source

pub fn crc3gsm() -> CRCu8

CheckPolyInitRefXorOut
0x40x30x0false0x7
let mut crc = CRCu8::crc3gsm();
crc.digest(b"123456789");
assert_eq!("0x4", &crc.to_string());
source

pub fn crc4itu() -> CRCu8

CheckPolyInitRefXorOut
0x70x3 (rev: 0xC)0x0true0x0
let mut crc = CRCu8::crc4itu();
crc.digest(b"123456789");
assert_eq!("0x7", &crc.to_string());
source

pub fn crc4interlaken() -> CRCu8

CheckPolyInitRefXorOut
0xB0x30xFfalse0xF
let mut crc = CRCu8::crc4interlaken();
crc.digest(b"123456789");
assert_eq!("0xB", &crc.to_string());
source

pub fn crc5epc() -> CRCu8

CheckPolyInitRefXorOut
0x000x090x09false0x00
let mut crc = CRCu8::crc5epc();
crc.digest(b"123456789");
assert_eq!("0x00", &crc.to_string());
source

pub fn crc5itu() -> CRCu8

CheckPolyInitRefXorOut
0x070x15 (rev: 0x15)0x00true0x00
let mut crc = CRCu8::crc5itu();
crc.digest(b"123456789");
assert_eq!("0x07", &crc.to_string());
source

pub fn crc5usb() -> CRCu8

CheckPolyInitRefXorOut
0x190x05 (rev: 0x14)0x1Ftrue0x1F
let mut crc = CRCu8::crc5usb();
crc.digest(b"123456789");
assert_eq!("0x19", &crc.to_string());
source

pub fn crc6cdma2000_a() -> CRCu8

CheckPolyInitRefXorOut
0x0D0x270x3Ffalse0x00
let mut crc = CRCu8::crc6cdma2000_a();
crc.digest(b"123456789");
assert_eq!("0x0D", &crc.to_string());
source

pub fn crc6cdma2000_b() -> CRCu8

CheckPolyInitRefXorOut
0x3B0x070x3Ffalse0x00
let mut crc = CRCu8::crc6cdma2000_b();
crc.digest(b"123456789");
assert_eq!("0x3B", &crc.to_string());
source

pub fn crc6darc() -> CRCu8

CheckPolyInitRefXorOut
0x260x19 (rev: 0x26)0x00true0x00
let mut crc = CRCu8::crc6darc();
crc.digest(b"123456789");
assert_eq!("0x26", &crc.to_string());
source

pub fn crc6gsm() -> CRCu8

CheckPolyInitRefXorOut
0x130x2F0x00false0x3F
let mut crc = CRCu8::crc6gsm();
crc.digest(b"123456789");
assert_eq!("0x13", &crc.to_string());
source

pub fn crc6itu() -> CRCu8

CheckPolyInitRefXorOut
0x060x03 (rev: 0x30)0x00true0x00
let mut crc = CRCu8::crc6itu();
crc.digest(b"123456789");
assert_eq!("0x06", &crc.to_string());
source

pub fn crc7() -> CRCu8

CheckPolyInitRefXorOut
0x750x090x00false0x00
let mut crc = CRCu8::crc7();
crc.digest(b"123456789");
assert_eq!("0x75", &crc.to_string());
source

pub fn crc7umts() -> CRCu8

CheckPolyInitRefXorOut
0x610x450x00false0x00
let mut crc = CRCu8::crc7umts();
crc.digest(b"123456789");
assert_eq!("0x61", &crc.to_string());
source

pub fn crc8() -> CRCu8

CheckPolyInitRefXorOut
0xF40x070x00false0x00
let mut crc = CRCu8::crc8();
crc.digest(b"123456789");
assert_eq!("0xF4", &crc.to_string());
source

pub fn crc8cdma2000() -> CRCu8

CheckPolyInitRefXorOut
0xDA0x9B0xFFfalse0x00
let mut crc = CRCu8::crc8cdma2000();
crc.digest(b"123456789");
assert_eq!("0xDA", &crc.to_string());
source

pub fn crc8darc() -> CRCu8

CheckPolyInitRefXorOut
0x150x39 (rev: 0x9C)0x00true0x00
let mut crc = CRCu8::crc8darc();
crc.digest(b"123456789");
assert_eq!("0x15", &crc.to_string());
source

pub fn crc8dvb_s2() -> CRCu8

CheckPolyInitRefXorOut
0xBC0xD50x00false0x00
let mut crc = CRCu8::crc8dvb_s2();
crc.digest(b"123456789");
assert_eq!("0xBC", &crc.to_string());
source

pub fn crc8ebu() -> CRCu8

CheckPolyInitRefXorOut
0x970x1D (rev: 0xB8)0xFFtrue0x00
let mut crc = CRCu8::crc8ebu();
crc.digest(b"123456789");
assert_eq!("0x97", &crc.to_string());
source

pub fn crc8icode() -> CRCu8

CheckPolyInitRefXorOut
0x7E0x1D0xFDfalse0x00
let mut crc = CRCu8::crc8icode();
crc.digest(b"123456789");
assert_eq!("0x7E", &crc.to_string());
source

pub fn crc8itu() -> CRCu8

CheckPolyInitRefXorOut
0xA10x070x00false0x55
let mut crc = CRCu8::crc8itu();
crc.digest(b"123456789");
assert_eq!("0xA1", &crc.to_string());
source

pub fn crc8maxim() -> CRCu8

CheckPolyInitRefXorOut
0xA10x31 (rev: 0x8C)0x00true0x00
let mut crc = CRCu8::crc8maxim();
crc.digest(b"123456789");
assert_eq!("0xA1", &crc.to_string());
source

pub fn crc8rohc() -> CRCu8

CheckPolyInitRefXorOut
0xD00x07 (rev: 0xE0)0xFFtrue0x00
let mut crc = CRCu8::crc8rohc();
crc.digest(b"123456789");
assert_eq!("0xD0", &crc.to_string());
source

pub fn crc8wcdma() -> CRCu8

CheckPolyInitRefXorOut
0x250x9B (rev: 0xD9)0x00true0x00
let mut crc = CRCu8::crc8wcdma();
crc.digest(b"123456789");
assert_eq!("0x25", &crc.to_string());

Trait Implementations§

source§

impl Debug for CRCu8

source§

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

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

impl Display for CRCu8

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for CRCu8

§

impl RefUnwindSafe for CRCu8

§

impl Send for CRCu8

§

impl Sync for CRCu8

§

impl Unpin for CRCu8

§

impl UnwindSafe for CRCu8

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.