pub struct Cnpj { /* private fields */ }Expand description
A validated CNPJ stored as 14 ASCII bytes.
Positions 0-11 may contain 0-9 or A-Z (alphanumeric CNPJ).
Positions 12-13 are always numeric digits (check digits).
use stdbr_core::cnpj::{Cnpj, CnpjKind, generate_cnpj};
let cnpj = generate_cnpj(CnpjKind::Numeric);
assert_eq!(cnpj.as_str().len(), 14);
assert_eq!(cnpj.to_string().len(), 18); // XX.XXX.XXX/XXXX-DD
let parsed: Cnpj = cnpj.to_string().parse().unwrap();
assert_eq!(cnpj, parsed);Implementations§
Source§impl Cnpj
impl Cnpj
Sourcepub fn establishment_type(&self) -> EstablishmentType
pub fn establishment_type(&self) -> EstablishmentType
Whether this is Matriz (ordem == “0001”) or Filial.
Sourcepub fn check_digits(&self) -> (u8, u8)
pub fn check_digits(&self) -> (u8, u8)
The two check digits (d1, d2) as numeric values.
Trait Implementations§
impl Copy for Cnpj
impl Eq for Cnpj
impl StructuralPartialEq for Cnpj
Auto Trait Implementations§
impl Freeze for Cnpj
impl RefUnwindSafe for Cnpj
impl Send for Cnpj
impl Sync for Cnpj
impl Unpin for Cnpj
impl UnsafeUnpin for Cnpj
impl UnwindSafe for Cnpj
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