/cfi-rs

Support for creating, validating and describing CFI codes in Rust.

Primary LanguageRustApache License 2.0Apache-2.0

cfi

A memory efficient CFI type for working with validated Classification of Financial Instruments (CFIs) as defined in ISO 10962.

Usage

Add this to your Cargo.toml:

[dependencies]
cfi = { version = "0.1", git = "https://github.com/procrustus/cfi-rs" }

Example

use cfi;

let cfi_string = "ESVUFR";

match cfi::parse(cfi_string) {
    Ok(code) => {
        println!("Parsed CFI: {}", code.to_string()); // "ESVUFR"
        println!("  Category: {}", code.category()); // 'E'
        println!("  Group: {}", code.group()); // 'S'
        println!("  Attributes: {:?}", code.attributes()); // ['V', 'U', 'F', 'R']
    }
    Err(err) => panic!("Unable to parse CFI `{}`: {}.", cfi_string, err),
}

Related crates

This is heavily inspired by the Financial Identifier series created by Gregor Purdy:

By me:

  • CFI

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.