ChecksumEngine

Struct ChecksumEngine 

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

An engine which consumes one GF32 character at a time, and produces a residue modulo some generator

Implementations§

Source§

impl Engine

Source

pub fn new_codex32_short() -> Engine

Source

pub fn new_codex32_long() -> Engine

Source

pub fn force_residue_to_zero(&mut self)

When computing checksums of “diffs” you do may want to set the highest-degree coefficient of the polynomial to 1.

If you do not know exactly why you are using this function, you should not use it.

Source

pub fn into_residue(self) -> Vec<Fe>

Extracts the residue from a checksum engine

Source

pub fn is_valid(&self) -> bool

Determines whether the residue matches the target value for the checksum

If you need the actual residue, e.g. for error correction, call the into_residue function (which will consume the engine).

Source

pub fn input_hrp(&mut self, hrp: &str) -> Result<(), Error>

Initializes the checksum engine by loading an HRP into it

Source

pub fn input_char(&mut self, c: char) -> Result<(), Error>

Adds a single character to the checksum engine

Source

pub fn input_data_str(&mut self, s: &str) -> Result<(), Error>

Adds an entire string to the engine, counting each character as a data character (not an HRP).

Source

pub fn input_own_target(&mut self)

Adds the target residue to the end of the input string

Source

pub fn input_fe(&mut self, e: Fe)

Adds a single field element to the checksum engine

This is where the real magic happens.

Trait Implementations§

Source§

impl Clone for Engine

Source§

fn clone(&self) -> Engine

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Engine

Source§

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

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

impl PartialEq for Engine

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Engine

Source§

impl StructuralPartialEq for Engine

Auto Trait Implementations§

§

impl Freeze for Engine

§

impl RefUnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl UnwindSafe for Engine

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 = 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>,

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.