npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

rust_iso9362

v0.1.0

Published

ISO 9362 (Business Identifier Code, also known as the SWIFT/BIC code) defines a standard format for identifying business parties – in particular banks and financial institutions – in financial transactions. This crate parses, validates and decomposes BIC

Readme

rust_iso/iso9362

A rust crate providing ISO 9362 (Business Identifier Code / BIC, a.k.a. SWIFT code) parsing and validation.

What is ISO 9362

ISO 9362 is an international standard for Business Identifier Codes (BIC), a standard published by the International Organization for Standardization (ISO) as a way to uniquely identify banks and financial institutions worldwide. The BIC is also known as the SWIFT code, SWIFT-BIC, or SWIFT address.

A BIC is 8 or 11 characters long and is made up of:

  • Business party prefix – four alphabetic characters identifying the business party (institution / bank code).
  • Country code – two alphabetic characters, the ISO 3166-1 alpha-2 code of the country in which the business party is located.
  • Business party suffix – two alphanumeric characters (the location code).
  • Branch code – an optional three alphanumeric characters identifying a specific branch; XXX, or its absence, denotes the primary office.

-- Wikipedia

Unlike ISO 3166, ISO 9362 does not define a fixed, enumerable dataset (the full registry of assigned BICs is maintained by SWIFT), so this crate is a parser / validator that decomposes a BIC into its component parts.

| Position | Part | Length | Charset | |----------|----------------------------|--------|------------| | 1–4 | Business party prefix | 4 | A-Z | | 5–6 | Country code (ISO 3166-1) | 2 | A-Z | | 7–8 | Business party suffix | 2 | A-Z0-9 | | 9–11 | Branch code (optional) | 3 | A-Z0-9 |

Installing

[dependencies]
rust_iso9362 = "0.1.0"

Features

  • serde — implements Serialize/Deserialize for BIC. A BIC serialises to its canonical code string and deserialises case-insensitively via BIC::parse. Enable with:

    rust_iso9362 = { version = "0.1.0", features = ["serde"] }
  • iso3166 — adds BIC::country(), which resolves the embedded ISO 3166-1 country code to a rust_iso3166::CountryCode using the rust_iso3166 crate.

  • cli — builds the iso9362 command-line lookup tool (pulls in prettytable-rs). Off by default; install with cargo install rust_iso9362 --features cli.

The minimum supported Rust version is 1.85.

Using

// Parse + validate (returns Option)
let bic = rust_iso9362::parse("DEUTDEFF500").unwrap();

// Or get a Result with a descriptive error
let bic = rust_iso9362::BIC::parse("DEUTDEFF500").unwrap();

assert_eq!(bic.business_party_prefix(), "DEUT"); // a.k.a. bank_code()
assert_eq!(bic.country_code(), "DE");
assert_eq!(bic.business_party_suffix(), "FF");   // a.k.a. location_code()
assert_eq!(bic.branch_code(), Some("500"));
assert_eq!(bic.bic8(), "DEUTDEFF");
assert_eq!(bic.bic11(), "DEUTDEFF500");
assert!(!bic.is_primary_office());

// 8-character BICs identify the primary office
let bic = rust_iso9362::BIC::parse("DEUTDEFF").unwrap();
assert_eq!(bic.branch_code(), None);
assert!(bic.is_primary_office());
assert_eq!(bic.bic11(), "DEUTDEFFXXX");

// Cheap validity check
assert!(rust_iso9362::is_valid("NEDSZAJJXXX"));
assert!(!rust_iso9362::is_valid("123"));

// FromStr is implemented too
let bic: rust_iso9362::BIC = "DEUTDEFF".parse().unwrap();

// With the `iso3166` feature:
// let country = bic.country().unwrap();
// assert_eq!(country.alpha3, "DEU");

Data sample:

BIC {
    code: "DEUTDEFF500",
    // business_party_prefix: "DEUT",
    // country_code:          "DE",
    // business_party_suffix: "FF",
    // branch_code:           Some("500"),
}

Contributing

Feel free to submit a pull request or create an issue. or request to rust-iso

License

rust-iso/rust_iso9362 is licensed under the Apache-2.0 license.

Source(s)