pub struct BaseIban { /* private fields */ }Expand description
Represents an IBAN that passed basic checks, but not necessarily the BBAN validation. This corresponds to the validation as described in ISO 13616-1.
To be exact, the IBAN must start with two uppercase ASCII letters, followed by two digits, followed by any number of digits and ASCII letters. Additionally its checksum should be valid. It should either contain no whitespace, or be in the paper format, where characters are in space-separated groups of four.
Note that most useful methods are supplied by the trait IbanLike. The Display trait provides pretty
print formatting.
§Examples
An example of parsing and using a correct IBAN:
use iban::{BaseIban, IbanLike};
let iban: BaseIban = "MR13 0002 0001 0100 0012 3456 753".parse()?;
assert_eq!(iban.electronic_str(), "MR1300020001010000123456753");
// The pretty print format
assert_eq!(iban.to_string(), "MR13 0002 0001 0100 0012 3456 753");
assert_eq!(iban.country_code(), "MR");
assert_eq!(iban.check_digits_str(), "13");
assert_eq!(iban.check_digits(), 13);
assert_eq!(iban.bban_unchecked(), "00020001010000123456753");An example of parsing invalid IBANs:
use iban::{BaseIban, ParseBaseIbanError};
assert_eq!(
"MR$$".parse::<BaseIban>(),
Err(ParseBaseIbanError::InvalidFormat)
);
assert_eq!(
"MR0000020001010000123456754".parse::<BaseIban>(),
Err(ParseBaseIbanError::InvalidChecksum)
);Trait Implementations§
Source§impl FromStr for BaseIban
impl FromStr for BaseIban
Source§fn from_str(address: &str) -> Result<Self, Self::Err>
fn from_str(address: &str) -> Result<Self, Self::Err>
Parse a basic iban without taking the BBAN into consideration.
§Errors
If the string does not match the IBAN format or the checksum is
invalid, an ParseBaseIbanError will be
returned.
Source§type Err = ParseBaseIbanError
type Err = ParseBaseIbanError
Source§impl IbanLike for BaseIban
impl IbanLike for BaseIban
Source§fn electronic_str(&self) -> &str
fn electronic_str(&self) -> &str
Source§fn country_code(&self) -> &str
fn country_code(&self) -> &str
Source§fn check_digits_str(&self) -> &str
fn check_digits_str(&self) -> &str
check_digits. Read moreSource§fn check_digits(&self) -> u8
fn check_digits(&self) -> u8
check_digits_str. Read moreSource§fn bban_unchecked(&self) -> &str
fn bban_unchecked(&self) -> &str
&str. Note that the BBAN is not
necessarily valid if this is not guaranteed by the implementing type.
Use Iban::bban to guarantee a correct BBAN. Read moreSource§impl<'a> TryFrom<&'a str> for BaseIban
impl<'a> TryFrom<&'a str> for BaseIban
Source§fn try_from(value: &'a str) -> Result<Self, Self::Error>
fn try_from(value: &'a str) -> Result<Self, Self::Error>
Parse a basic IBAN without taking the BBAN into consideration.
§Errors
If the string does not match the IBAN format or the checksum is
invalid, an ParseBaseIbanError will be
returned.
Source§type Error = ParseBaseIbanError
type Error = ParseBaseIbanError
Source§impl TryFrom<BaseIban> for Iban
impl TryFrom<BaseIban> for Iban
Source§fn try_from(base_iban: BaseIban) -> Result<Iban, ParseIbanError>
fn try_from(base_iban: BaseIban) -> Result<Iban, ParseIbanError>
Parse an IBAN without taking the BBAN into consideration.
§Errors
If the string does not match the IBAN format or the checksum is
invalid, ParseIbanError::InvalidBaseIban will be
returned. If the country format is invalid or unknown, the other
variants will be returned with the BaseIban giving
access to some basic functionality nonetheless.
Source§type Error = ParseIbanError
type Error = ParseIbanError
impl Copy for BaseIban
impl Eq for BaseIban
impl StructuralPartialEq for BaseIban
Auto Trait Implementations§
impl Freeze for BaseIban
impl RefUnwindSafe for BaseIban
impl Send for BaseIban
impl Sync for BaseIban
impl Unpin for BaseIban
impl UnwindSafe for BaseIban
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
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)
clone_to_uninit)