8 releases

0.1.7 Jul 4, 2023
0.1.6 Apr 24, 2023
0.0.1 Apr 4, 2023

#255 in Algorithms

Download history 2507/week @ 2024-07-29 2056/week @ 2024-08-05 1909/week @ 2024-08-12 1938/week @ 2024-08-19 2759/week @ 2024-08-26 3729/week @ 2024-09-02 2754/week @ 2024-09-09 2434/week @ 2024-09-16 1759/week @ 2024-09-23 2224/week @ 2024-09-30 894/week @ 2024-10-07 3097/week @ 2024-10-14 3720/week @ 2024-10-21 3721/week @ 2024-10-28 3552/week @ 2024-11-04 3103/week @ 2024-11-11

14,236 downloads per month

MIT/Apache

43KB
765 lines

IBAN

Crates.io Docs Coverage Status Licensed

This is a crate for working with International Bank Account Numbers (IBANs).

An IBAN is an international standard for identifying bank accounts. It consists of a country code, two check digits, and a Basic Bank Account Number (BBAN) that includes a bank identifier, a branch identifier, and a checksum (if applicable).

This crate provides a simple implementation of IBANs. You can construct an IBAN using a string, and then query it for its country code, and check digits. You can also obtain spaced or electronic formatting using the Display, Debug, Deref, or AsRef implementations.

This crate also provides a Bban struct that represents the BBAN portion of an IBAN. You can construct a BBAN using the Iban::bban function, and then query it for it's bank identifier, branch identifier, or checksum.

Usage

Add library as a dependency to Cargo.toml.

...
[dependencies]
iban = "0.1"
...

Construct a Iban type by using str::parse, FromStr::from_str, or Iban::parse.

use iban::{Bban, Iban};
let iban: Iban = "AA110011123Z5678"
    .parse()
    .unwrap_or_else(|err| {
        // This example panics, but you should handle the error cases properly.
        panic!("invalid iban: {err}");
    });

let country_code: &str = iban.country_code();
let bban: Bban = iban.bban();

let bank_identifier: Option<&str> = bban.bank_identifier();

References

Dependencies

~0.4–1MB
~18K SLoC