[][src]Struct iban::BaseIban

pub struct BaseIban { /* fields omitted */ }

Represents an IBAN that passed basic checks, but not necessarily the BBAN validation. To be exact, the IBAN must be of the correct length, start with two uppercase ASCII letters, followed by two digits, followed by any number of digits and uppercase ASCII letters. Additionally its checksum should be valid. It should either contain no whitespace, or every block of four characters can be separated by a space.

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

impl Clone for BaseIban[src]

impl Copy for BaseIban[src]

impl Debug for BaseIban[src]

impl Display for BaseIban[src]

impl Eq for BaseIban[src]

impl From<Iban> for BaseIban[src]

impl FromStr for BaseIban[src]

type Err = ParseBaseIbanError

The associated error which can be returned from parsing.

impl Hash for BaseIban[src]

impl IbanLike for BaseIban[src]

impl PartialEq<BaseIban> for BaseIban[src]

impl StructuralEq for BaseIban[src]

impl StructuralPartialEq for BaseIban[src]

impl<'a> TryFrom<&'a str> for BaseIban[src]

type Error = ParseBaseIbanError

The type returned in the event of a conversion error.

impl TryFrom<BaseIban> for Iban[src]

type Error = ParseIbanError

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.