Expand description
§rust_iso9362
ISO 9362 defines the Business Identifier Code (BIC), more commonly known as the SWIFT code. Unlike ISO 3166 (a finite, enumerable list of country codes) a BIC is defined by its structure, so this crate is a parser / validator rather than a static dataset.
A BIC is 8 or 11 characters long and is composed of four 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 |
The business party prefix is also called the institution / bank code and the business party suffix the location code.
§Sample code
let bic = rust_iso9362::parse("DEUTDEFF500").unwrap();
assert_eq!(bic.business_party_prefix(), "DEUT");
assert_eq!(bic.country_code(), "DE");
assert_eq!(bic.business_party_suffix(), "FF");
assert_eq!(bic.branch_code(), Some("500"));
assert_eq!(bic.bic8(), "DEUTDEFF");
// 8-character BICs identify the primary office
let bic = rust_iso9362::parse("DEUTDEFF").unwrap();
assert_eq!(bic.branch_code(), None);
assert!(bic.is_primary_office());
assert_eq!(bic.bic11(), "DEUTDEFFXXX");
assert!(rust_iso9362::is_valid("DEUTDEFF"));
assert!(!rust_iso9362::is_valid("123"));Structs§
- BIC
- A parsed, validated ISO 9362 Business Identifier Code.
Enums§
- Parse
Error - The error returned when a string is not a valid ISO 9362 BIC.