Skip to main content

Crc

Struct Crc 

Source
pub struct Crc { /* private fields */ }
Expand description

A cyclic redundancy check of degree width and generator poly (without its leading term), valid by construction (Crc::new checks them).

Implementations§

Source§

impl Crc

Source

pub fn new(name: &'static str, width: u32, poly: u64) -> Result<Crc>

A CRC of degree width (1 to 64) and generator poly without its leading term.

§Errors

Error::Config for a degree outside 1 to 64 or a generator with bits above it.

Source

pub fn name(&self) -> &'static str

Name of the CRC.

Source

pub fn width(&self) -> u32

Degree $L$.

Source

pub fn poly(&self) -> u64

Generator polynomial without its leading term $D^{L}$.

Source

pub fn crc24a() -> Crc

CRC24A of 5G NR.

Source

pub fn crc24b() -> Crc

CRC24B of 5G NR.

Source

pub fn crc24c() -> Crc

CRC24C of 5G NR.

Source

pub fn crc16() -> Crc

CRC16 of 5G NR and of LTE, $g_{\mathrm{CRC16}}(D) = D^{16} + D^{12} + D^{5} + 1$ (CCITT).

Source

pub fn crc11() -> Crc

CRC11 of 5G NR.

Source

pub fn crc6() -> Crc

CRC6 of 5G NR.

Source

pub fn from_name(name: &str) -> Result<Crc>

A CRC of 5G NR by name: crc24a, crc24b, crc24c, crc16, crc11 or crc6 (case-insensitive).

§Errors

Error::Config for another name.

Source

pub fn checksum(&self, bits: &[u8]) -> Vec<u8> ⓘ

The $L$ parity bits of bits: the remainder of $b(D), D^{L}$ by the generator (comnum_math::gf2::poly_rem).

Source

pub fn attach(&self, bits: &[u8]) -> Vec<u8> ⓘ

bits followed by their parity bits.

Source

pub fn check(&self, word: &[u8]) -> bool

Whether a word (information then parity bits) passes the check.

Trait Implementations§

Source§

impl Clone for Crc

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Crc

Source§

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

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

impl Eq for Crc

Source§

impl PartialEq for Crc

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Crc

Auto Trait Implementations§

§

impl Forget for Crc

§

impl Freeze for Crc

§

impl RefUnwindSafe for Crc

§

impl Send for Crc

§

impl Sync for Crc

§

impl Unpin for Crc

§

impl UnsafeUnpin for Crc

§

impl UnwindSafe for Crc

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.