Struct idcard::Identity[][src]

pub struct Identity { /* fields omitted */ }
Expand description

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) -> &str[src]

Returns the ID number.

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

Returns the formatted 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 day(&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<&str>[src]

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

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

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

pub fn region_code(&self) -> Option<&str>[src]

Returns the region code(the first 6 digits)

pub fn constellation(&self) -> Option<&str>[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<&str>[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.

pub fn to_json_string(&self, pretty: bool) -> String[src]

Converts the value to a JSON string.

Trait Implementations

impl Clone for Identity[src]

fn clone(&self) -> Identity[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Identity[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Ord for Identity[src]

fn cmp(&self, other: &Identity) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

impl PartialEq<Identity> for Identity[src]

fn eq(&self, other: &Identity) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Identity) -> bool[src]

This method tests for !=.

impl PartialOrd<Identity> for Identity[src]

fn partial_cmp(&self, other: &Identity) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Eq for Identity[src]

impl StructuralEq for Identity[src]

impl StructuralPartialEq for Identity[src]

Auto Trait Implementations

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

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

pub fn vzip(self) -> V