8 releases

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

#442 in Parser implementations

Download history 3191/week @ 2024-01-01 4179/week @ 2024-01-08 3535/week @ 2024-01-15 4243/week @ 2024-01-22 4945/week @ 2024-01-29 5634/week @ 2024-02-05 6282/week @ 2024-02-12 4550/week @ 2024-02-19 5533/week @ 2024-02-26 5578/week @ 2024-03-04 6546/week @ 2024-03-11 5321/week @ 2024-03-18 2771/week @ 2024-03-25 4907/week @ 2024-04-01 4474/week @ 2024-04-08 3555/week @ 2024-04-15

15,722 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