Struct crc_any::CRCu16

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

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

Implementations§

source§

impl CRCu16

source

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

Create a CRCu16 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) -> u16

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

source§

impl CRCu16

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 CRCu16

source

pub fn crc10() -> CRCu16

CheckPolyInitRefXorOut
0x1990x2330x000false0x000
let mut crc = CRCu16::crc10();
crc.digest(b"123456789");
assert_eq!("0x199", &crc.to_string());
source

pub fn crc10cdma2000() -> CRCu16

CheckPolyInitRefXorOut
0x2330x3D90x3FFfalse0x000
let mut crc = CRCu16::crc10cdma2000();
crc.digest(b"123456789");
assert_eq!("0x233", &crc.to_string());
source

pub fn crc10gsm() -> CRCu16

CheckPolyInitRefXorOut
0x12A0x1750x000false0x3FF
let mut crc = CRCu16::crc10gsm();
crc.digest(b"123456789");
assert_eq!("0x12A", &crc.to_string());
source

pub fn crc11() -> CRCu16

CheckPolyInitRefXorOut
0x5A30x3850x01afalse0x000
let mut crc = CRCu16::crc11();
crc.digest(b"123456789");
assert_eq!("0x5A3", &crc.to_string());
source

pub fn crc12() -> CRCu16

CheckPolyInitRefXorOut
0xF5B0x80F0x000false0x000
let mut crc = CRCu16::crc12();
crc.digest(b"123456789");
assert_eq!("0xF5B", &crc.to_string());
source

pub fn crc12cdma2000() -> CRCu16

CheckPolyInitRefXorOut
0xD4D0xF130xFFFfalse0x000
let mut crc = CRCu16::crc12cdma2000();
crc.digest(b"123456789");
assert_eq!("0xD4D", &crc.to_string());
source

pub fn crc12gsm() -> CRCu16

CheckPolyInitRefXorOut
0xB340xD310x000false0xFFF
let mut crc = CRCu16::crc12gsm();
crc.digest(b"123456789");
assert_eq!("0xB34", &crc.to_string());
source

pub fn crc13bbc() -> CRCu16

CheckPolyInitRefXorOut
0x04FA0x1CF50x0000false0x0000
let mut crc = CRCu16::crc13bbc();
crc.digest(b"123456789");
assert_eq!("0x04FA", &crc.to_string());
source

pub fn crc14darc() -> CRCu16

CheckPolyInitRefXorOut
0x082D0x0805 (rev: 0x2804)0x0000true0x0000
let mut crc = CRCu16::crc14darc();
crc.digest(b"123456789");
assert_eq!("0x082D", &crc.to_string());
source

pub fn crc14gsm() -> CRCu16

CheckPolyInitRefXorOut
0x30AE0x202D0x0000false0x3FFF
let mut crc = CRCu16::crc14gsm();
crc.digest(b"123456789");
assert_eq!("0x30AE", &crc.to_string());
source

pub fn crc15can() -> CRCu16

CheckPolyInitRefXorOut
0x059E0x45990x0000false0x0000
let mut crc = CRCu16::crc15can();
crc.digest(b"123456789");
assert_eq!("0x059E", &crc.to_string());
source

pub fn crc15mpt1327() -> CRCu16

CheckPolyInitRefXorOut
0x25660x68150x0000false0x0001
let mut crc = CRCu16::crc15mpt1327();
crc.digest(b"123456789");
assert_eq!("0x2566", &crc.to_string());
source

pub fn crc16() -> CRCu16

CheckPolyInitRefXorOut
0xBB3D0x8005 (rev: 0xA001)0x0000true0x0000
let mut crc = CRCu16::crc16();
crc.digest(b"123456789");
assert_eq!("0xBB3D", &crc.to_string());
source

pub fn crc16ccitt_false() -> CRCu16

CheckPolyInitRefXorOut
0x29B10x10210xFFFFfalse0x0000
let mut crc = CRCu16::crc16ccitt_false();
crc.digest(b"123456789");
assert_eq!("0x29B1", &crc.to_string());
source

pub fn crc16aug_ccitt() -> CRCu16

CheckPolyInitRefXorOut
0xE5CC0x10210x1D0Ffalse0x0000
let mut crc = CRCu16::crc16aug_ccitt();
crc.digest(b"123456789");
assert_eq!("0xE5CC", &crc.to_string());
source

pub fn crc16buypass() -> CRCu16

CheckPolyInitRefXorOut
0xFEE80x80050x0000false0x0000
let mut crc = CRCu16::crc16buypass();
crc.digest(b"123456789");
assert_eq!("0xFEE8", &crc.to_string());
source

pub fn crc16cdma2000() -> CRCu16

CheckPolyInitRefXorOut
0x4C060xC8670xFFFFfalse0x0000
let mut crc = CRCu16::crc16cdma2000();
crc.digest(b"123456789");
assert_eq!("0x4C06", &crc.to_string());
source

pub fn crc16dds_110() -> CRCu16

CheckPolyInitRefXorOut
0x9ECF0x80050x800Dfalse0x0000
let mut crc = CRCu16::crc16dds_110();
crc.digest(b"123456789");
assert_eq!("0x9ECF", &crc.to_string());
source

pub fn crc16dect_r() -> CRCu16

CheckPolyInitRefXorOut
0x007E0x05890x0000false0x0001
let mut crc = CRCu16::crc16dect_r();
crc.digest(b"123456789");
assert_eq!("0x007E", &crc.to_string());
source

pub fn crc16dect_x() -> CRCu16

CheckPolyInitRefXorOut
0x007F0x05890x0000false0x0000
let mut crc = CRCu16::crc16dect_r();
crc.digest(b"123456789");
assert_eq!("0x007E", &crc.to_string());
source

pub fn crc16dnp() -> CRCu16

CheckPolyInitRefXorOut
0xEA820x3D65 (rev: 0xA6BC)0x0000true0xFFFF
let mut crc = CRCu16::crc16dnp();
crc.digest(b"123456789");
assert_eq!("0xEA82", &crc.to_string());
source

pub fn crc16en_13757() -> CRCu16

CheckPolyInitRefXorOut
0xC2B70x3D650x0000false0xFFFF
let mut crc = CRCu16::crc16en_13757();
crc.digest(b"123456789");
assert_eq!("0xC2B7", &crc.to_string());
source

pub fn crc16genibus() -> CRCu16

CheckPolyInitRefXorOut
0xD64E0x10210xFFFFfalse0xFFFF
let mut crc = CRCu16::crc16genibus();
crc.digest(b"123456789");
assert_eq!("0xD64E", &crc.to_string());
source

pub fn crc16maxim() -> CRCu16

CheckPolyInitRefXorOut
0x44C20x8005 (rev: 0xA001)0xFFFFtrue0xFFFF
let mut crc = CRCu16::crc16maxim();
crc.digest(b"123456789");
assert_eq!("0x44C2", &crc.to_string());
source

pub fn crc16mcrf4cc() -> CRCu16

CheckPolyInitRefXorOut
0x6F910x1021 (rev: 0x8408)0xFFFFtrue0x0000
let mut crc = CRCu16::crc16mcrf4cc();
crc.digest(b"123456789");
assert_eq!("0x6F91", &crc.to_string());
source

pub fn crc16riello() -> CRCu16

CheckPolyInitRefXorOut
0x63D00x1021 (rev: 0x8408)0xB2AAtrue0x0000
let mut crc = CRCu16::crc16riello();
crc.digest(b"123456789");
assert_eq!("0x63D0", &crc.to_string());
source

pub fn crc16t10_dif() -> CRCu16

CheckPolyInitRefXorOut
0xD0DB0x8BB70x0000false0x0000
let mut crc = CRCu16::crc16t10_dif();
crc.digest(b"123456789");
assert_eq!("0xD0DB", &crc.to_string());
source

pub fn crc16teledisk() -> CRCu16

CheckPolyInitRefXorOut
0x0FB30xA0970x0000false0x0000
let mut crc = CRCu16::crc16teledisk();
crc.digest(b"123456789");
assert_eq!("0x0FB3", &crc.to_string());
source

pub fn crc16tms13157() -> CRCu16

CheckPolyInitRefXorOut
0x26B10x1021 (rev: 0x8408)0x89ECtrue0x0000
let mut crc = CRCu16::crc16tms13157();
crc.digest(b"123456789");
assert_eq!("0x26B1", &crc.to_string());
source

pub fn crc16usb() -> CRCu16

CheckPolyInitRefXorOut
0xB4C80x8005 (rev: 0xA001)0xFFFFtrue0xFFFF
let mut crc = CRCu16::crc16usb();
crc.digest(b"123456789");
assert_eq!("0xB4C8", &crc.to_string());
source

pub fn crc_a() -> CRCu16

CheckPolyInitRefXorOut
0xBF050x1021 (rev: 0x8408)0xC6C6true0x0000
let mut crc = CRCu16::crc_a();
crc.digest(b"123456789");
assert_eq!("0xBF05", &crc.to_string());
source

pub fn crc16kermit() -> CRCu16

CheckPolyInitRefXorOut
0x21890x1021 (rev: 0x8408)0x0000true0x0000
let mut crc = CRCu16::crc16kermit();
crc.digest(b"123456789");
assert_eq!("0x2189", &crc.to_string());
source

pub fn crc16modbus() -> CRCu16

CheckPolyInitRefXorOut
0x4B370x8005 (rev: 0xA001)0xFFFFtrue0x0000
let mut crc = CRCu16::crc16modbus();
crc.digest(b"123456789");
assert_eq!("0x4B37", &crc.to_string());
source

pub fn crc16_x25() -> CRCu16

CheckPolyInitRefXorOut
0x906E0x8005 (rev: 0xA001)0xFFFFtrue0xFFFF
let mut crc = CRCu16::crc16_x25();
crc.digest(b"123456789");
assert_eq!("0x906E", &crc.to_string());
source

pub fn crc16xmodem() -> CRCu16

CheckPolyInitRefXorOut
0x31C30x10210x0000false0x0000
let mut crc = CRCu16::crc16xmodem();
crc.digest(b"123456789");
assert_eq!("0x31C3", &crc.to_string());

Trait Implementations§

source§

impl Debug for CRCu16

source§

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

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

impl Display for CRCu16

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for CRCu16

§

impl RefUnwindSafe for CRCu16

§

impl Send for CRCu16

§

impl Sync for CRCu16

§

impl Unpin for CRCu16

§

impl UnwindSafe for CRCu16

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.