Struct cusip::CINS

source ·
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:

  1. 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");
    }
  2. 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),
    }
  3. 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>

source

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());
source

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");
source

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');
source

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().

source

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.

source

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");
source

pub fn issue_num(&self) -> &str

Return just the Issue Number portion of the CINS.

Trait Implementations§

source§

impl<'a> Clone for CINS<'a>

source§

fn clone(&self) -> CINS<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for CINS<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Display for CINS<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Hash for CINS<'a>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a> Ord for CINS<'a>

source§

fn cmp(&self, other: &CINS<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<'a> PartialEq for CINS<'a>

source§

fn eq(&self, other: &CINS<'a>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a> PartialOrd for CINS<'a>

source§

fn partial_cmp(&self, other: &CINS<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a> TryFrom<&'a CUSIP> for CINS<'a>

§

type Error = &'static str

The type returned in the event of a conversion error.
source§

fn try_from(cusip: &'a CUSIP) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<'a> Eq for CINS<'a>

source§

impl<'a> StructuralPartialEq for CINS<'a>

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for CINS<'a>

§

impl<'a> Send for CINS<'a>

§

impl<'a> Sync for CINS<'a>

§

impl<'a> Unpin for CINS<'a>

§

impl<'a> UnwindSafe for CINS<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.