1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
//! # OpenFIGI Rust Client
//!
//! A high-performance Rust client library for the [OpenFIGI API](https://www.openfigi.com/api),
//! providing type-safe access to financial instrument identification and mapping services.
//!
//! OpenFIGI is Bloomberg's open symbology initiative that provides standardized identification
//! for financial instruments across asset classes and markets worldwide.
//!
//! ## Quick Start
//!
//! ### Basic Usage
//!
//! ```rust,no_run
//! use openfigi_rs::client::OpenFIGIClient;
//! use openfigi_rs::model::enums::IdType;
//! use serde_json::json;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client (uses OPENFIGI_API_KEY env var if available)
//! let client = OpenFIGIClient::new();
//!
//! // Map an ISIN to FIGI
//! let mapping_results = client
//! .mapping(IdType::IdIsin, json!("US4592001014"))
//! .send()
//! .await?;
//!
//! // Access the FIGI from the first result
//! if let Some(data) = mapping_results[0].data() {
//! println!("FIGI: {}", data[0].figi);
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ### With API Key
//!
//! ```rust,no_run
//! use openfigi_rs::client::OpenFIGIClient;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Explicit API key configuration
//! let client = OpenFIGIClient::builder()
//! .api_key("your-api-key")
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Custom HTTP Configuration
//!
//! ```rust,no_run
//! use openfigi_rs::client::OpenFIGIClient;
//! use reqwest_middleware::ClientBuilder;
//! use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};
//! use std::time::Duration;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! // Configure HTTP client with retry middleware
//! let http_client = reqwest::Client::builder()
//! .timeout(Duration::from_secs(30))
//! .build()?;
//!
//! let retry_policy = ExponentialBackoff::builder().build_with_max_retries(3);
//! let middleware_client = ClientBuilder::new(http_client)
//! .with(RetryTransientMiddleware::new_with_policy(retry_policy))
//! .build();
//!
//! let client = OpenFIGIClient::builder()
//! .middleware_client(middleware_client)
//! .api_key("your-api-key")
//! .build()?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Authentication & Rate Limits
//!
//! - **Without API key**: 25 requests per minute, max 5 requests per batch
//! - **With API key**: 25 requests per 6 seconds, max 100 requests per batch
//! - **API key**: Set via `OPENFIGI_API_KEY` environment variable or explicit configuration
//!
//! ## API Endpoints
//!
//! | Endpoint | Purpose | Batch Support |
//! |----------|---------|---------------|
//! | `/mapping` | Map identifiers to FIGIs | ✓ |
//! | `/search` | Search instruments by text | ✗ |
//! | `/filter` | Filter instruments by criteria | ✗ |
//!
//! ## Features
//!
//! - **Type-safe API**: Strongly typed request/response models with validation
//! - **Async/await**: Built on `reqwest` with full async support and connection pooling
//! - **Middleware support**: Extensible HTTP middleware for retries, logging, and observability
//! - **Comprehensive error handling**: Detailed error types with OpenFIGI-specific context
//! - **Rate limit awareness**: Automatic rate limit detection and informative error messages
//! - **Environment integration**: Automatic API key detection from environment variables
//! - **Production ready**: Connection pooling, timeouts, and efficient resource management
/// HTTP client for OpenFIGI API operations
/// Client builder with fluent configuration API for custom HTTP settings
/// API endpoint implementations for mapping, search, and filter operations
/// Comprehensive error types with OpenFIGI-specific context and inspection methods
/// Strongly typed request and response data models for all API operations
/// Internal HTTP request builder utilities (not intended for direct use)
pub
use LazyLock;
use Url;
/// Library version
pub const VERSION: &str = env!;
/// The default base URL for the OpenFIGI API v3.
///
/// This URL is used by default when creating clients without explicit base URL configuration.
pub static DEFAULT_BASE_URL: = new;
/// The default endpoint path for mapping requests.
///
/// Used for converting between different financial identifier types.
pub const DEFAULT_ENDPOINT_MAPPING: &str = "mapping";
/// The default endpoint path for search requests.
///
/// Used for text-based instrument search operations.
pub const DEFAULT_ENDPOINT_SEARCH: &str = "search";
/// The default endpoint path for filter requests.
///
/// Used for filtering instruments by specific criteria.
pub const DEFAULT_ENDPOINT_FILTER: &str = "filter";
/// API key loaded from the `OPENFIGI_API_KEY` environment variable.
///
/// This is automatically loaded at startup and used by default when creating clients.
/// `None` if the environment variable is not set.
static API_KEY: = new;