[−][src]Struct luhn::Luhn
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]
S: AsRef<str>,
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]
S: AsRef<str>,
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]
S: AsRef<str>,
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]
S: AsRef<str>,
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,