Skip to main content

marketdata_core/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2#![doc = include_str!("../README.md")]
3#![deny(missing_docs, rustdoc::broken_intra_doc_links, clippy::missing_errors_doc)]
4
5pub mod errors;
6#[cfg(all(feature = "test-utils", feature = "tokio-comp"))]
7#[cfg_attr(docsrs, doc(cfg(feature = "test-utils")))]
8pub mod testing;
9pub mod models;
10pub mod rest;
11pub mod tls;
12pub mod urls;
13pub mod websocket;
14
15// Internal: cfg-gated tracing macro re-exports. No-op when the `tracing`
16// feature is disabled.
17mod tracing_compat;
18
19// Internal: cfg-gated `metrics` crate integration. Provides `DropCounter`
20// (clone-cheap atomic + optional metrics::Counter wrapper) and the
21// SDK-registered counter names. No-op when the `metrics` feature is
22// disabled — the wrapper compiles to a single-Arc allocation.
23mod metrics_compat;
24
25// Re-export error types
26pub use errors::{ErrorKind, MarketDataError, WebSocketErrorKind};
27
28// Re-export TLS config
29pub use tls::TlsConfig;
30
31// Re-export REST client types
32pub use rest::{Auth, RestClient, RetryPolicy};
33
34// Re-export WebSocket types
35pub use websocket::{
36    ConnectionConfig, ConnectionEvent, ConnectionState, DisconnectIntent, HealthCheckConfig,
37    MessageReceiver, ReconnectionConfig, WebSocketClient, WebSocketFactory,
38};
39
40// Re-export WebSocket config constants for binding layers (CON-01).
41// 3.0 collapsed `interval × max_missed_pongs` into a single timeout
42// window — bindings that previously exposed both fields now expose
43// just `heartbeat_timeout_ms`.
44pub use websocket::health_check::{
45    DEFAULT_HEALTH_CHECK_ENABLED, DEFAULT_HEARTBEAT_TIMEOUT_MS, MIN_HEARTBEAT_TIMEOUT_MS,
46};
47pub use websocket::reconnection::{
48    DEFAULT_INITIAL_DELAY_MS, DEFAULT_MAX_ATTEMPTS, DEFAULT_MAX_DELAY_MS, MIN_INITIAL_DELAY_MS,
49};
50
51// Re-export model types for convenience
52pub use models::{
53    // Common types
54    PriceLevel, ResponseMeta, TotalStats, TradeInfo, TradingHalt,
55    // REST response types
56    HistoricalCandle, HistoricalCandlesResponse, IntradayCandle, IntradayCandlesResponse,
57    Quote, Ticker, Trade, TradesResponse, VolumeAtPrice, VolumesResponse,
58    // WebSocket types
59    AuthRequest, Channel, Symbols, UnsubscribeRequest, WebSocketMessage, WebSocketRequest,
60};
61
62// Re-export streaming message types (Phase 4)
63pub use models::streaming::{
64    AggregatesData, BooksData, CandleData, CandleHistoryItem, CandlesSnapshot, DataPayload,
65    ErrorData, IndicesData, SnapshotPayload, StreamMessage, StreamTrade, SubscribedData,
66    TradesData,
67};
68
69// Re-export channel subscription and parsing utilities (Phase 4)
70pub use websocket::channels::{parse_channel_data, parse_stream_message, ChannelData};
71pub use websocket::StockSubscription;
72
73// Re-export FutOpt types (Phase 5)
74pub use models::futopt::{
75    ContractType, FutOptChannel, FutOptLastTrade, FutOptPriceLevel, FutOptQuote, FutOptSession,
76    FutOptTicker, FutOptTotalStats, FutOptType, OptionRight, Product, ProductsResponse,
77};
78pub use websocket::channels::FutOptSubscription;
79
80// Re-export the async module + runtime (gated behind `tokio-comp`).
81#[cfg(feature = "tokio-comp")]
82#[cfg_attr(docsrs, doc(cfg(feature = "tokio-comp")))]
83pub use websocket::aio;
84#[cfg(feature = "tokio-comp")]
85#[cfg_attr(docsrs, doc(cfg(feature = "tokio-comp")))]
86pub use websocket::aio::AsyncRuntime;
87
88// Future modules (to be added in later phases):
89// pub mod rest;
90// pub mod ws;