Struct idcard::Identity[][src]

pub struct Identity { /* fields omitted */ }

An object representation of the Chinese ID.

Implementations

impl Identity[src]

pub fn new(number: &str) -> Self[src]

Creates an identity object from given number.

pub fn number(&self) -> String[src]

Returns the ID number.

pub fn birth_date(&self) -> Option<String>[src]

Returns the date of birth(yyyy-mm-dd).

pub fn year(&self) -> Option<i32>[src]

Returns the year of birth.

pub fn month(&self) -> Option<i32>[src]

Returns the month of birth.

pub fn date(&self) -> Option<i32>[src]

Returns the day in the month of the birth.

pub fn age(&self) -> Option<u32>[src]

Calculates the current age based on the computer’s local date, if the birth year is less than the local’s, it returns None.

pub fn age_in_year(&self, year: u32) -> Option<u32>[src]

Calculates the age based on the given year, if the given year is less than the birth year, it returns None.

pub fn gender(&self) -> Option<Gender>[src]

Returns the gender.

pub fn province(&self) -> Option<String>[src]

Returns the province name based on the first 2 digits of the number

pub fn region(&self) -> Option<String>[src]

Returns the region name based on the first 6 digits of the number

pub fn constellation(&self) -> Option<String>[src]

Returns the constellation by the date of birth.

pub fn chinese_era(&self) -> Option<String>[src]

Returns the Chinese Era by the year of birth.

pub fn chinese_zodiac(&self) -> Option<String>[src]

Returns the Chinese Zodiac animal by the year of birth.

pub fn is_valid(&self) -> bool[src]

Checks if the number is valid.

pub fn is_empty(&self) -> bool[src]

Checks if the number is empty.

pub fn len(&self) -> usize[src]

Returns the length of the number.

Trait Implementations

impl Debug for Identity[src]

impl PartialEq<Identity> for Identity[src]

impl PartialOrd<Identity> for Identity[src]

impl StructuralPartialEq for Identity[src]

Auto Trait Implementations

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,