1use crate::models::{
2 Board, Candle, CandleBorder, Engine, Index, IndexAnalytics, Market, OrderbookLevel, SecStat,
3 Security, SecurityBoard, SecuritySnapshot, Trade, Turnover,
4};
5#[cfg(feature = "news")]
6use crate::models::{Event, SiteNews};
7#[cfg(feature = "history")]
8use crate::models::{HistoryDates, HistoryRecord};
9
10use super::MoexError;
11use super::constants::{
12 BOARDS_ENDPOINT_TEMPLATE, CANDLEBORDERS_ENDPOINT_TEMPLATE, CANDLES_ENDPOINT_TEMPLATE,
13 INDEX_ANALYTICS_ENDPOINT_TEMPLATE, MARKETS_ENDPOINT_TEMPLATE, ORDERBOOK_ENDPOINT_TEMPLATE,
14 SECSTATS_ENDPOINT_TEMPLATE, SECURITIES_ENDPOINT_TEMPLATE, SECURITY_BOARDS_ENDPOINT_TEMPLATE,
15 TRADES_ENDPOINT_TEMPLATE, TURNOVERS_ENDPOINT,
16};
17#[cfg(feature = "news")]
18use super::constants::{EVENTS_ENDPOINT, SITENEWS_ENDPOINT};
19#[cfg(feature = "history")]
20use super::constants::{HISTORY_DATES_ENDPOINT_TEMPLATE, HISTORY_ENDPOINT_TEMPLATE};
21pub use super::payload::{RawTableView, RawTables};
22use super::payload::{
23 decode_board_security_snapshots_json_with_endpoint, decode_boards_json_with_endpoint,
24 decode_candle_borders_json_with_endpoint, decode_candles_json_with_endpoint,
25 decode_engines_json_payload, decode_index_analytics_json_with_endpoint,
26 decode_indexes_json_payload, decode_markets_json_with_endpoint,
27 decode_orderbook_json_with_endpoint, decode_raw_table_rows_json_with_endpoint,
28 decode_raw_table_view_json_with_endpoint, decode_raw_tables_json_with_endpoint,
29 decode_secstats_json_with_endpoint, decode_securities_json_with_endpoint,
30 decode_security_boards_json_with_endpoint, decode_trades_json_with_endpoint,
31 decode_turnovers_json_with_endpoint,
32};
33#[cfg(feature = "news")]
34use super::payload::{decode_events_json_with_endpoint, decode_sitenews_json_with_endpoint};
35#[cfg(feature = "history")]
36use super::payload::{decode_history_dates_json_with_endpoint, decode_history_json_with_endpoint};
37
38pub fn indexes_json(payload: &str) -> Result<Vec<Index>, MoexError> {
40 decode_indexes_json_payload(payload)
41}
42
43pub fn engines_json(payload: &str) -> Result<Vec<Engine>, MoexError> {
45 decode_engines_json_payload(payload)
46}
47
48pub fn markets_json(payload: &str) -> Result<Vec<Market>, MoexError> {
50 decode_markets_json_with_endpoint(payload, MARKETS_ENDPOINT_TEMPLATE)
51}
52
53pub fn boards_json(payload: &str) -> Result<Vec<Board>, MoexError> {
55 decode_boards_json_with_endpoint(payload, BOARDS_ENDPOINT_TEMPLATE)
56}
57
58pub fn security_boards_json(payload: &str) -> Result<Vec<SecurityBoard>, MoexError> {
60 decode_security_boards_json_with_endpoint(payload, SECURITY_BOARDS_ENDPOINT_TEMPLATE)
61}
62
63pub fn securities_json(payload: &str) -> Result<Vec<Security>, MoexError> {
65 decode_securities_json_with_endpoint(payload, SECURITIES_ENDPOINT_TEMPLATE)
66}
67
68pub fn board_security_snapshots_json(payload: &str) -> Result<Vec<SecuritySnapshot>, MoexError> {
70 decode_board_security_snapshots_json_with_endpoint(payload, SECURITIES_ENDPOINT_TEMPLATE)
71}
72
73pub fn orderbook_json(payload: &str) -> Result<Vec<OrderbookLevel>, MoexError> {
75 decode_orderbook_json_with_endpoint(payload, ORDERBOOK_ENDPOINT_TEMPLATE)
76}
77
78pub fn candle_borders_json(payload: &str) -> Result<Vec<CandleBorder>, MoexError> {
80 decode_candle_borders_json_with_endpoint(payload, CANDLEBORDERS_ENDPOINT_TEMPLATE)
81}
82
83pub fn candles_json(payload: &str) -> Result<Vec<Candle>, MoexError> {
85 decode_candles_json_with_endpoint(payload, CANDLES_ENDPOINT_TEMPLATE)
86}
87
88pub fn trades_json(payload: &str) -> Result<Vec<Trade>, MoexError> {
90 decode_trades_json_with_endpoint(payload, TRADES_ENDPOINT_TEMPLATE)
91}
92
93pub fn index_analytics_json(payload: &str) -> Result<Vec<IndexAnalytics>, MoexError> {
95 decode_index_analytics_json_with_endpoint(payload, INDEX_ANALYTICS_ENDPOINT_TEMPLATE)
96}
97
98pub fn turnovers_json(payload: &str) -> Result<Vec<Turnover>, MoexError> {
100 decode_turnovers_json_with_endpoint(payload, TURNOVERS_ENDPOINT)
101}
102
103pub fn secstats_json(payload: &str) -> Result<Vec<SecStat>, MoexError> {
105 decode_secstats_json_with_endpoint(payload, SECSTATS_ENDPOINT_TEMPLATE)
106}
107
108#[cfg(feature = "history")]
109pub fn history_dates_json(payload: &str) -> Result<Vec<HistoryDates>, MoexError> {
111 decode_history_dates_json_with_endpoint(payload, HISTORY_DATES_ENDPOINT_TEMPLATE)
112}
113
114#[cfg(feature = "history")]
115pub fn history_json(payload: &str) -> Result<Vec<HistoryRecord>, MoexError> {
117 decode_history_json_with_endpoint(payload, HISTORY_ENDPOINT_TEMPLATE)
118}
119
120#[cfg(feature = "news")]
121pub fn sitenews_json(payload: &str) -> Result<Vec<SiteNews>, MoexError> {
123 decode_sitenews_json_with_endpoint(payload, SITENEWS_ENDPOINT)
124}
125
126#[cfg(feature = "news")]
127pub fn events_json(payload: &str) -> Result<Vec<Event>, MoexError> {
129 decode_events_json_with_endpoint(payload, EVENTS_ENDPOINT)
130}
131
132pub fn raw_table_rows_json<T>(
137 payload: &str,
138 endpoint: &str,
139 table: &str,
140) -> Result<Vec<T>, MoexError>
141where
142 T: serde::de::DeserializeOwned,
143{
144 decode_raw_table_rows_json_with_endpoint(payload, endpoint, table)
145}
146
147pub fn raw_table_view_json<'a>(
151 payload: &'a str,
152 endpoint: &str,
153 table: &str,
154) -> Result<RawTableView<'a>, MoexError> {
155 decode_raw_table_view_json_with_endpoint(payload, endpoint, table)
156}
157
158pub fn raw_tables_json(payload: &str, endpoint: &str) -> Result<RawTables, MoexError> {
164 decode_raw_tables_json_with_endpoint(payload, endpoint)
165}