pub struct Iban { /* private fields */ }Expand description
Represents an IBAN. To obtain it, make use of the parse() function, which will make sure the
string follows the ISO 13616 standard. Apart from its own methods, Iban implements IbanLike,
which provides more functionality.
The impementation of Display provides spaced formatting of the IBAN. Electronic
formatting can be obtained via electronic_str.
A valid IBAN satisfies the defined format, has a valid checksum and has a BBAN format as defined in the IBAN registry.
§Examples
use iban::*;
let address = "KZ86125KZT5004100100".parse::<iban::Iban>()?;
assert_eq!(address.to_string(), "KZ86 125K ZT50 0410 0100");Implementations§
Source§impl Iban
impl Iban
Sourcepub fn bban(&self) -> &str
pub fn bban(&self) -> &str
Get the BBAN part of the IBAN, as a &str. This method, in contrast to IbanLike::bban_unchecked,
is only available on the Iban structure, which means the returned BBAN string is always correct.
§Example
use iban::*;
let iban: Iban = "DE44 5001 0517 5407 3249 31".parse()?;
assert_eq!(iban.bban(), "500105175407324931");Sourcepub fn bank_identifier(&self) -> Option<&str>
pub fn bank_identifier(&self) -> Option<&str>
Get the bank identifier of the IBAN. The bank identifier might not be
defined, in which case this method returns None.
§Example
use iban::*;
let iban: Iban = "AD12 0001 2030 2003 5910 0100".parse()?;
assert_eq!(iban.bank_identifier(), Some("0001"));Sourcepub fn branch_identifier(&self) -> Option<&str>
pub fn branch_identifier(&self) -> Option<&str>
Get the branch identifier of the IBAN. The branch identifier might not be
defined, in which case this method returns None.
§Example
use iban::*;
let iban: Iban = "AD12 0001 2030 2003 5910 0100".parse()?;
assert_eq!(iban.branch_identifier(), Some("2030"));Trait Implementations§
Source§impl IbanLike for Iban
impl IbanLike for Iban
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 Iban
impl<'a> TryFrom<&'a str> for Iban
Source§fn try_from(value: &'a str) -> Result<Self, Self::Error>
fn try_from(value: &'a str) -> Result<Self, Self::Error>
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
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 Iban
impl Eq for Iban
impl StructuralPartialEq for Iban
Auto Trait Implementations§
impl Freeze for Iban
impl RefUnwindSafe for Iban
impl Send for Iban
impl Sync for Iban
impl Unpin for Iban
impl UnwindSafe for Iban
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)