[][src]Struct luhn::Luhn

pub struct Luhn { /* fields omitted */ }

Luhn represents a thing that can generate or validate the Luhn character for a given input.

Implementations

impl Luhn[src]

pub fn new<S>(alphabet: S) -> Result<Luhn, LuhnError> where
    S: AsRef<str>, 
[src]

Create a new Luhn instance from anything that can be coerced to a &str.

pub fn generate<S>(&self, s: S) -> Result<char, LuhnError> where
    S: AsRef<str>, 
[src]

Given an input string, generate the Luhn character.

Returns an error if the input string is empty, or contains a character that is not in the input alphabet.

pub fn validate<S>(&self, s: S) -> Result<bool, LuhnError> where
    S: AsRef<str>, 
[src]

Validates a Luhn check character. This assumes that the final character of the input string is the Luhn character, and it will validate that the remainder of the string is correct.

pub fn validate_with<S>(&self, s: S, check: char) -> Result<bool, LuhnError> where
    S: AsRef<str>, 
[src]

Validates a Luhn check character. This is the same as the validate method, but allows providing the Luhn check character out-of-band from the input to validate.

Trait Implementations

impl Debug for Luhn[src]

Auto Trait Implementations

impl RefUnwindSafe for Luhn

impl Send for Luhn

impl Sync for Luhn

impl Unpin for Luhn

impl UnwindSafe for Luhn

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.