Struct idcard::Identity [−][src]
pub struct Identity { /* fields omitted */ }
An object representation of the Chinese ID.
Implementations
impl Identity
[src]
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 PartialOrd<Identity> for Identity
[src]
impl PartialOrd<Identity> for Identity
[src]impl StructuralPartialEq for Identity
[src]
impl StructuralPartialEq for Identity
[src]Auto Trait Implementations
impl RefUnwindSafe for Identity
impl RefUnwindSafe for Identity
impl UnwindSafe for Identity
impl UnwindSafe for Identity