[][src]Struct canada_sin::SIN

pub struct SIN { /* fields omitted */ }

A social insurance number.

Implementations

impl SIN[src]

pub fn parse(s: String) -> Result<Self, SINParseError>[src]

Parses a SIN from a string.

Examples

use canada_sin::SIN;
assert!(SIN::parse("046454286".to_string()).is_ok());

pub fn types(&self) -> Vec<SINType>[src]

All types the SIN could be. This will often be multiple options, since this is based on the first digit, and we are running out of numbers, so there is some overlap. However, the following can be determined unambiguously:

  • CRAAssigned (starts with 0)
  • TemporaryResident (starts with 9)
  • Quebec (starts with 2 or 3)
  • BusinessNumber sometimes (if it starts with 8 it's a business number, if it starts with 7 it might be one)

The logic is based on this mapping.

pub fn digits(self) -> [u8; 9][src]

Returns the parsed digits as an array of digits.

pub fn digits_string(self) -> String[src]

Returns the SIN as a string.

Examples

use canada_sin::SIN;
let sin = SIN::parse("046454286".to_string()).unwrap();
assert_eq!(sin.digits_string(), "046454286")

pub fn digits_dashed_string(self) -> String[src]

Returns the SIN as a string with dashes in it.

Examples

use canada_sin::SIN;
let sin = SIN::parse("046454286".to_string()).unwrap();
assert_eq!(sin.digits_dashed_string(), "046-454-286")

Trait Implementations

impl Clone for SIN[src]

impl Copy for SIN[src]

impl Debug for SIN[src]

impl Display for SIN[src]

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

Formats the SIN into three parts with dashes.

Examples

use canada_sin::SIN;
assert_eq!(
    format!("Your SIN is {}.", SIN::parse("046454286".to_string()).unwrap()),
    "Your SIN is 046-454-286.".to_string(),
);

impl Eq for SIN[src]

impl PartialEq<SIN> for SIN[src]

impl StructuralEq for SIN[src]

impl StructuralPartialEq for SIN[src]

Auto Trait Implementations

impl RefUnwindSafe for SIN

impl Send for SIN

impl Sync for SIN

impl Unpin for SIN

impl UnwindSafe for SIN

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> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[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.