Struct cnpj::Cnpj [−][src]
pub struct Cnpj { /* fields omitted */ }
A valid CNPJ number.
Initialize a Cnpj
from a &str
or an array of digits:
use cnpj::Cnpj; let cnpj1 = "96.769.900/0001-77".parse::<Cnpj>()?; let cnpj2 = Cnpj::try_from([9, 6, 7, 6, 9, 9, 0, 0, 0, 0, 0, 1, 7, 7])?; assert_eq!(cnpj1, cnpj2);
Note that the Cnpj
struct can only be initialized after a successfully parse,
so it is guaranteed to always be valid.
use cnpj::Cnpj; let cnpj = "00.000.000/0000-00".parse::<Cnpj>(); assert!(cnpj.is_err());
Implementations
impl Cnpj
[src]
pub fn digits(&self) -> &[u8; 14]
[src]
The Cnpj digits.
use cnpj::Cnpj; let cnpj: Cnpj = "96.769.900/0001-77".parse()?; assert_eq!(cnpj.digits(), &[9, 6, 7, 6, 9, 9, 0, 0, 0, 0, 0, 1, 7, 7]);
pub fn formatted(&self) -> ArrayString<18>
[src]
Formats a Cnpj number.
use cnpj::Cnpj; let cnpj: Cnpj = "96769900000177".parse()?; assert_eq!(cnpj.formatted().as_str(), "96.769.900/0001-77");
Note that numbers with less than 14 digits will be padded by zeros.
use cnpj::Cnpj; let cnpj: Cnpj = "1.219.900/0001-97".parse()?; assert_eq!(cnpj.formatted().as_str(), "01.219.900/0001-97");
Trait Implementations
impl Clone for Cnpj
[src]
impl Copy for Cnpj
[src]
impl Debug for Cnpj
[src]
impl Display for Cnpj
[src]
impl Eq for Cnpj
[src]
impl FromStr for Cnpj
[src]
type Err = ParseCnpjError
The associated error which can be returned from parsing.
fn from_str(s: &str) -> Result<Self, Self::Err>
[src]
impl Hash for Cnpj
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl PartialEq<Cnpj> for Cnpj
[src]
impl StructuralEq for Cnpj
[src]
impl StructuralPartialEq for Cnpj
[src]
impl TryFrom<&'_ str> for Cnpj
[src]
type Error = ParseCnpjError
The type returned in the event of a conversion error.
fn try_from(value: &str) -> Result<Self, Self::Error>
[src]
impl TryFrom<[u8; 14]> for Cnpj
[src]
Auto Trait Implementations
impl RefUnwindSafe for Cnpj
impl Send for Cnpj
impl Sync for Cnpj
impl Unpin for Cnpj
impl UnwindSafe for Cnpj
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
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]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,