# Countries (laravel-rust-iban)

> The IBAN country registry provides electronic lengths, BBAN structure, identifier ranges and SEPA and EU status.

- Package: laravel-rust-iban (Laravel for Rust, alpha), crates: `laravel-rust-iban`, `laravel-rust-iban-core`
- Maintenance: active; Latest release: 0.1.0 (2026-12-05); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-iban), [crates.io](https://crates.io/crates/laravel-rust-iban/0.1.0), [docs.rs](https://docs.rs/laravel-rust-iban/0.1.0), [Changelog](https://oss.bowerbird.si/iban/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-iban/blob/322f32ccaf92144d5d5727285efc84ca03fd603e/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-iban/blob/322f32ccaf92144d5d5727285efc84ca03fd603e/SECURITY.md)
- Based on: [globalcitizen/php-iban](https://github.com/globalcitizen/php-iban): Reference behavior for the independent Rust implementation.
- PHP parity: core (14 covered, 34 diverged, 11 planned of 59 abilities; 565 fixtures; follows globalcitizen/php-iban v5.03b; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/iban/docs/countries/
- Source: https://github.com/bowerbird-si/laravel-rust-iban/blob/322f32ccaf92144d5d5727285efc84ca03fd603e/docs/countries.md

The IBAN country registry provides electronic lengths, BBAN structure, identifier ranges and SEPA and EU status.

## The registry

The package supports the 89 prefixes in SWIFT IBAN Registry Release 103, dated September 2026.
An unregistered prefix returns `Error::UnknownCountry` during parsing. French overseas departments
use `FR`, the Åland Islands use `FI`, and Guernsey, Jersey and the Isle of Man use `GB`.

English country names use Unicode CLDR 49.0.0. SEPA status follows EPC409-09 v8.0, published in December 2025. EU status follows the EU member list.

## Look up a country

`country` takes a two-letter code in either case and returns `Option<&'static Country>`. `countries`
returns every record, in prefix order. A parsed `Iban` gives its own record with `iban.country()`.

```rust
use laravel_rust_iban::country;

fn main() {
    let Some(belgium) = country("be") else { return };

    assert_eq!(belgium.code(), "BE");
    assert_eq!(belgium.name(), "Belgium");
    assert_eq!(belgium.iban_length(), 16);
    assert_eq!(belgium.bban_length(), 12);
    assert_eq!(belgium.bban_structure(), "3!n7!n2!n");
    assert_eq!(belgium.iban_structure(), "BE2!n3!n7!n2!n");
    assert_eq!(belgium.bank_id_range(), Some(0..=2));
    assert_eq!(belgium.national_check_digits_range(), Some(10..=11));
    assert!(belgium.is_sepa());
    assert!(belgium.is_eu_member());

    assert!(country("ZZ").is_none());
}
```

## Fields

| Method | Returns |
| --- | --- |
| `code()` | The two-letter IBAN prefix |
| `name()` | The English name |
| `iban_length()`, `bban_length()` | The electronic lengths, as `u8` |
| `iban_structure()`, `bban_structure()` | The structure in SWIFT notation, such as `3!n7!n2!n` |
| `iban_pattern()`, `bban_pattern()` | The structure as an anchored regular expression, for the [`regex`](https://crates.io/crates/regex) crate |
| `bank_id_range()`, `branch_id_range()`, `national_check_digits_range()` | Zero-based inclusive positions in the BBAN, or `None` |
| `is_sepa()` | Whether the country takes part in the SEPA schemes |
| `is_eu_member()` | Whether the country is an EU member state |
| `swift_official()` | `true` for every supported country |

The SWIFT notation uses `n` for digits, `a` for uppercase letters, `c` for uppercase letters and digits,
and `e` for a space. Each field has a fixed length such as `3!n`. The parser checks each BBAN byte
against its field.
