[−][src]Struct upc_checker::UPC
Main UPC structure containing the base UPC code alonside it's
check digit. This is the core of the upc_checker
library
Params
- upc: A
UPCStandard
enum - check_digit: An i8 int for the UPC code's check digit
Examples
NOTE: The below example is a demo and will not work with the given upc code & check digit in practise.
extern crate upc_checker; let my_code_vector = upc_checker::UPCStandard::UPCA( [0,1,2,3,4,5,6,7,8,9,0] ); // NOTE digits should be 0-9. let my_check_digit: i8 = 2; // NOTE check digit should be 0-9 let my_upc_code = upc_checker::UPC { upc: my_code_vector, check_digit: my_check_digit, }; match my_upc_code.check_upc() { Ok(x) => println!("Is the code valid?: {}", x), Err(upc_checker::UPCError::UPCOverflow) => { println!("UPC code overflow! Please use only 0-9!"); }, Err(upc_checker::UPCError::CheckDigitOverflow) => { println!("UPC check digit overflow! Please use only 0-9!"); }, };
Fields
upc: UPCStandard
check_digit: i8
Methods
impl UPC
[src]
pub fn check_upc(&self) -> Result<bool, UPCError>
[src]
The main frontend method for the UPC
structure. This method uses
data from the super UPC
struct and returns a Result enum with
either a bool
(IF the check digit is valid) or an instance of the
UPCError
enum.
NOTE: For more documentation & examples, please view the UPC
documentation directly.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
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> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,