[][src]Trait checkdigit::prelude::CheckDigitAlgo

pub trait CheckDigitAlgo {
    fn validate(&self, protected: &str) -> Result<bool, Error>;
fn generate(&self, unprotected: &str) -> Result<String, Error>;
fn compute(&self, unprotected: &str) -> Result<String, Error>; }

Defines minimum common operations of check digit algorithms.

Required methods

fn validate(&self, protected: &str) -> Result<bool, Error>

Returns true if the argument is valid according to the algorithm. The argument must be a protected string that consists of an original string and check digit(s).

fn generate(&self, unprotected: &str) -> Result<String, Error>

Generates a valid protected string for the argument according to the algorithm. This method returns a combined string of the original string and computed check digit(s).

fn compute(&self, unprotected: &str) -> Result<String, Error>

Computes the check digit(s) for the argument. Unlike generate(), this method returns the check digit(s) only.

Loading content...

Implementors

Loading content...