pub struct SIN { /* private fields */ }
Expand description
A social insurance number.
Implementations§
Source§impl SIN
impl SIN
Sourcepub fn parse(s: String) -> Result<Self, SINParseError>
pub fn parse(s: String) -> Result<Self, SINParseError>
Parses a SIN from a string.
§Examples
use canada_sin::SIN;
assert!(SIN::parse("046454286".to_string()).is_ok());
Sourcepub fn types(&self) -> Vec<SINType>
pub fn types(&self) -> Vec<SINType>
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.
Sourcepub fn digits_string(self) -> String
pub fn digits_string(self) -> String
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")
Sourcepub fn digits_dashed_string(self) -> String
pub fn digits_dashed_string(self) -> String
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 Copy for SIN
impl Eq for SIN
impl StructuralPartialEq for SIN
Auto Trait Implementations§
impl Freeze for SIN
impl RefUnwindSafe for SIN
impl Send for SIN
impl Sync for SIN
impl Unpin for SIN
impl UnwindSafe for SIN
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)