[−][src]Struct jmbg::JMBG
Implementations
impl<'_> JMBG<'_>
[src]
pub fn day(&self) -> Result<u8, ParseIntError>
[src]
Returns day of birth.
pub fn month(&self) -> Result<u8, ParseIntError>
[src]
Returns month of birth.
pub fn year(&self) -> Result<u16, ParseIntError>
[src]
Returns year of birth.
Since JMBG holds last 3 digits of year, I can only guess what is the first digit.
Algorithm guesses by checking if 3 digit year is greater than 870 and adds 1 to the beginning.
If it isn't greater than 870, it adds 2 to the beginning.
pub fn region_num(&self) -> Result<u8, ParseIntError>
[src]
Returns regional number.
pub fn region(&self) -> Result<(&str, &str), ParseIntError>
[src]
Returns region and country based on regional number.
If region is empty or regional number represents foreigner or something similar
string is empty.
pub fn birth_num(&self) -> Result<u16, ParseIntError>
[src]
Birth number (id).
pub fn gender(&self) -> Result<Gender, ParseIntError>
[src]
Returns gender. If birth number is less than 500 returns male, else female.
pub fn checksum(&self) -> Option<u8>
[src]
Last digit of JMBG is reserved for checksum.
pub fn is_valid(&self) -> Result<bool, ParseIntError>
[src]
Checks if JMBG is valid by checking if checksum passes.
Formula for checksum is:
m = 11 − (( 7*(a+g) + 6*(b+h) + 5*(c+i) + 4*(d+j) + 3*(e+k) + 2*(f+l) ) mod 11)
- If m is between 1 and 9, the number checksum is the same as the number m
- If m is 10 or 11 checksum becomes 0
Where a, b, c, d, e, f, g, h, i, j, k, l, m are digits of JMBG.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for JMBG<'a>
impl<'a> Send for JMBG<'a>
impl<'a> Sync for JMBG<'a>
impl<'a> Unpin for JMBG<'a>
impl<'a> UnwindSafe for JMBG<'a>
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>,