codes_iso_10383/
lib.rs

1/*!
2This package contains an implementation of the
3[ISO-10383](https://www.iso.org/standard/61067.html) Securities and related
4financial instruments — Codes for exchanges and Market Identification (MIC)
5specification.
6
7ISO 10383 specifies a universal method of identifying exchanges, trading
8platforms, regulated or non-regulated markets and trade reporting facilities
9as sources of prices and related information in order to facilitate automated
10processing.
11
12It is intended for use in any application and communication for identification of places
13
14* where a financial instrument is listed (place of official listing),
15* where a related trade is executed (place of trade), and
16* where trade details are reported (trade reporting facility).
17
18Note that field descriptions are taken from ISO 10383 Market Identifier Codes - [Release 2.0 Factsheet](https://www.iso20022.org/sites/default/files/2022-11/ISO10383_MIC_Release_2_0_Factsheet_v2.pdf).
19
20# Example
21
22```rust
23use codes_iso_10383::{Category, MarketIdCode, Status};
24
25let market = MarketIdCode::XNCM;
26assert_eq!(market.code(), "XNCM");
27assert_eq!(market.operating_code(), Some(MarketIdCode::XNAS));
28assert_eq!(market.is_segment(), true);
29assert_eq!(market.status(), Status::Active);
30assert_eq!(market.market_category_code(), Some(Category::NSPD));
31assert_eq!(market.acronym(), None);
32
33// feature = "real_url"
34// assert_eq!(market.website_url(), Some(url::Url::from_str("http://www.nasdaq.com").unwrap()));
35// or
36// assert_eq!(market.website_url(), Some("http://www.nasdaq.com"));
37
38// feature = "market_name"
39// assert_eq!(market.market_name(), "NASDAQ CAPITAL MARKET");
40
41// feature = "location"
42// assert_eq!(market.country_code(), Some(CountryCode::US));
43// assert_eq!(market.city(), Some("NEW YORK"));
44
45// feature = "legal_entity"
46// assert_eq!(market.legal_entity_name(), None);
47// assert_eq!(market.legal_entity_id(), None);
48
49// feature = "dates"
50// assert_eq!(market.creation_date(), "2008-02-25");
51// assert_eq!(market.last_update_date(), Some("2008-02-25"));
52// assert_eq!(market.last_validation_date(), None);
53// assert_eq!(market.expiration_date(), None);
54
55// feature = "comments"
56// assert_eq!(market.comments(), Some("..."));
57```
58
59The following demonstrates the `from_str_extended` which searches the
60acronym values *if* there is not a direct MIC match via `from_str`.
61
62```rust
63use codes_iso_10383::MarketIdCode;
64use std::str::FromStr;
65
66assert!(MarketIdCode::from_str("NASDAQ").is_err());
67
68let market = MarketIdCode::from_str_extended("NASDAQ");
69assert!(market.is_ok());
70assert_eq!(market.unwrap().code(), "XNAS");
71```
72
73# Features
74
75By default only the `serde` feature is enabled, the [MarketIdCode::code] and
76[MarketIdCode::operating_code], and [MarketIdCode::is_segment] methods cannot be excluded.
77
78* `serde` - Enables serialization of the [MarketIdCode] type.
79* `market_name` - Adds the [MarketIdCode::market_name] method.
80* `location` - Adds the [MarketIdCode::country_code] and [MarketIdCode::city] methods.
81* `legal_entity` - Adds the [MarketIdCode::legal_entity_id] and [MarketIdCode::legal_entity_name] methods.
82* `real_url - Uses the `Url` type from the `url` crate for the [MarketIdCode::website_url] method.
83* `dates` - Adds the [MarketIdCode::creation_date], [MarketIdCode::last_update_date], [MarketIdCode::last_validation_date], and [MarketIdCode::expiration_date] methods.
84* `real_dates` - Used the `DateTime<Utc>` types from the `chrono` crate for date functions **Work In Progress**
85* `comments` - Adds the [MarketIdCode::comments] method.
86
87*/
88
89#![warn(
90    unknown_lints,
91    // ---------- Stylistic
92    absolute_paths_not_starting_with_crate,
93    elided_lifetimes_in_paths,
94    explicit_outlives_requirements,
95    macro_use_extern_crate,
96    nonstandard_style, /* group */
97    noop_method_call,
98    rust_2018_idioms,
99    single_use_lifetimes,
100    trivial_casts,
101    trivial_numeric_casts,
102    // ---------- Future
103    future_incompatible, /* group */
104    rust_2021_compatibility, /* group */
105    // ---------- Public
106    missing_debug_implementations,
107    // missing_docs,
108    unreachable_pub,
109    // ---------- Unsafe
110    unsafe_code,
111    unsafe_op_in_unsafe_fn,
112    // ---------- Unused
113    unused, /* group */
114)]
115#![deny(
116    // ---------- Public
117    exported_private_dependencies,
118    private_in_public,
119    // ---------- Deprecated
120    anonymous_parameters,
121    bare_trait_objects,
122    ellipsis_inclusive_range_patterns,
123    // ---------- Unsafe
124    deref_nullptr,
125    drop_bounds,
126    dyn_drop,
127)]
128
129// ------------------------------------------------------------------------------------------------
130//
131// The rest of this file is generated by the package build script.
132//
133// ------------------------------------------------------------------------------------------------
134
135include!(concat!(env!("OUT_DIR"), "/generated.rs"));
136
137// ------------------------------------------------------------------------------------------------
138// Modules
139// ------------------------------------------------------------------------------------------------
140
141#[doc(hidden)]
142mod category;
143pub use category::Category;
144
145#[doc(hidden)]
146mod status;
147pub use status::Status;