Struct iban::BaseIban[][src]

pub struct BaseIban { /* fields omitted */ }
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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

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.

The associated error which can be returned from parsing.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Get the IBAN in the electronic format, without whitespace. This method is simply a view into the inner string. Read more

Get the country code of the IBAN. This method simply returns a slice of the inner representation. Read more

Get the check digits of the IBAN, as a string slice. This method simply returns a slice of the inner representation. To obtain an integer instead, use check_digits. Read more

Get the check digits of the IBAN. This method parses the digits to an integer, performing slightly more work than check_digits_str. Read more

Get the BBAN part of the IBAN, as a &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 more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

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.

The type returned in the event of a conversion 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.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.