pub struct CINS<'a>(/* private fields */);
Expand description
A CINS (CUSIP International Numbering System) identifier.
CINS is a subset of CUSIP used for international securities. It is distinguished by having a letter as the first character.
§Creating CINS instances
There are several ways to create a CINS
instance from a CUSIP
:
-
Using
CINS::new
:use cusip::{CUSIP, CINS}; let cusip = CUSIP::parse("S08000AA9").unwrap(); if let Some(cins) = CINS::new(&cusip) { println!("CINS: {}", cins); } else { println!("Not a valid CINS"); }
-
Using
TryFrom<&CUSIP>
:use cusip::{CUSIP, CINS}; use std::convert::TryFrom; let cusip = CUSIP::parse("S08000AA9").unwrap(); match CINS::try_from(&cusip) { Ok(cins) => println!("CINS: {}", cins), Err(err) => println!("Error: {}", err), }
-
Using
CUSIP::as_cins
:use cusip::{CUSIP, CINS}; let cusip = CUSIP::parse("S08000AA9").unwrap(); if let Some(cins) = cusip.as_cins() { println!("CINS: {}", cins); } else { println!("Not a valid CINS"); }
§Accessing the underlying CUSIP
You can call as_cusip
on a CINS
instance to access the underlying CUSIP
:
use cusip::{CUSIP, CINS};
let cusip = CUSIP::parse("S08000AA9").unwrap();
let cins = CINS::new(&cusip).unwrap();
println!("CUSIP: {}", cins.as_cusip());
Implementations§
source§impl<'a> CINS<'a>
impl<'a> CINS<'a>
sourcepub fn new(cusip: &'a CUSIP) -> Option<Self>
pub fn new(cusip: &'a CUSIP) -> Option<Self>
Constructs a new CINS
from a reference to a CUSIP
.
Returns Some(CINS)
if the given CUSIP
is a valid CINS identifier,
i.e., its first character is a letter (A-Z). Otherwise, returns None
.
§Examples
use cusip::{CUSIP, CINS};
let cusip = CUSIP::parse("S08000AA9").unwrap();
let cins = CINS::new(&cusip).unwrap();
let non_cins_cusip = CUSIP::parse("037833100").unwrap();
assert!(CINS::new(&non_cins_cusip).is_none());
sourcepub fn as_cusip(&self) -> &CUSIP
pub fn as_cusip(&self) -> &CUSIP
Returns a reference to the underlying CUSIP
.
§Examples
use cusip::{CUSIP, CINS};
let cusip = CUSIP::parse("S08000AA9").unwrap();
let cins = CINS::new(&cusip).unwrap();
assert_eq!(cins.as_cusip().to_string(), "S08000AA9");
sourcepub fn country_code(&self) -> char
pub fn country_code(&self) -> char
Returns the CINS country code.
The country code is the first character of the CINS identifier, which is always a letter (A-Z).
§Examples
use cusip::{CUSIP, CINS};
let cusip = CUSIP::parse("S08000AA9").unwrap();
let cins = CINS::new(&cusip).unwrap();
assert_eq!(cins.country_code(), 'S');
sourcepub fn is_base(&self) -> bool
pub fn is_base(&self) -> bool
Returns true if this CUSIP identifier is actually a CUSIP International Numbering System
(CINS) identifier (with the further restriction that it does not use ‘I’, ‘O’ or ‘Z’ as
its country code), false otherwise. See also is_cins()
and is_cins_extended()
.
sourcepub fn is_extended(&self) -> bool
pub fn is_extended(&self) -> bool
Returns true if this CUSIP identifier is actually a CUSIP International Numbering System (CINS) identifier (with the further restriction that it does use ‘I’, ‘O’ or ‘Z’ as its country code), false otherwise.
sourcepub fn issuer_num(&self) -> &str
pub fn issuer_num(&self) -> &str
Returns the CINS issuer number.
The issuer number is the 5 characters following the country code in the CINS identifier.
§Examples
use cusip::{CUSIP, CINS};
let cusip = CUSIP::parse("S08000AA9").unwrap();
let cins = CINS::new(&cusip).unwrap();
assert_eq!(cins.issuer_num(), "08000");
Trait Implementations§
source§impl<'a> Ord for CINS<'a>
impl<'a> Ord for CINS<'a>
source§impl<'a> PartialEq for CINS<'a>
impl<'a> PartialEq for CINS<'a>
source§impl<'a> PartialOrd for CINS<'a>
impl<'a> PartialOrd for CINS<'a>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more