Skip to main content

futu_core/
lib.rs

1//! `futu-core` — 共享类型 / 错误 / 协议 ID / 日志
2//!
3//! ## 模块稳定性分层(v1.4.89 API audit)
4//!
5//! | Module | 稳定性 | 跨 crate 消费者 |
6//! |---|---|---|
7//! | [`error`] | **Stable** | futu-codec / futu-net / futu-qot / futu-trd / futu-gateway / futu-rest / futu-backend / futu-server |
8//! | [`proto_id`] | **Stable** | 同上 + futu-opend tests |
9//! | [`log`] | **Stable** | futu-opend 主程序 / examples / futu-mcp |
10//! | [`market`] | **Stable** | futu-gateway handlers / bridge |
11//! | [`exch_type`] | **Stable** (v1.4.93) | futu-gateway / futu-rest / futucli / futu-mcp / futu-qot |
12//! | [`account_locator`] | **Stable** (v1.4.109) | futu-cache / futu-trd / futu-rest / futu-mcp / futucli |
13//! | [`handler`] | **Internal** — 当前无 implementor,保留占位 | — |
14//!
15//! ### 稳定性约定
16//!
17//! - **Stable**:外部二进制(例如 futu-opend / futu-mcp)和 examples 可依赖。
18//!   修改(签名 / 枚举变体 / 字段)走 SemVer breaking 流程。
19//! - **Internal**:模块内 `pub` 但**不承诺稳定**,下版可能调整签名或 gate 为
20//!   `pub(crate)`。新外部调用方请 consult maintainer。
21
22/// C++ internal UI transport identity used only to reach the pre-login
23/// Verification flow without waiting for ordinary InitConnect completion.
24///
25/// Ref: `Src/APIServer/Business/APIServer_InitConnect.cpp:6,41-76` defines
26/// `UIClientID` and makes it the sole client allowed to complete InitConnect
27/// while gateway initialization is pending. This cannot come from server
28/// configuration because it is a peer-selected wire constant. It becomes
29/// invalid if upstream changes/removes that exact special case; replace it only
30/// when the C++ oracle and pre-login Verification transport change together.
31pub const INTERNAL_UI_CLIENT_ID: &str = "internal_client_ui";
32
33/// Stable API — 统一错误类型与 `Result<T>` 别名,跨 10+ crate 消费。
34pub mod error;
35pub mod heartbeat;
36
37/// Internal shared API — reqwest 0.13 Rustls builder with the repository's
38/// curated Mozilla webpki trust contract instead of platform/user roots.
39pub mod http_client;
40
41/// Shared Rust product version-manifest decision and fetch runtime.
42pub mod update_check;
43
44/// Internal shared API — C++ FTLogin server-time anchor and delay calibration.
45pub mod server_time;
46
47/// Stable API — 日志初始化入口(stderr fmt / JSON / audit-jsonl 三种模式)。
48/// futu-opend / futu-mcp / examples 用。
49pub mod log;
50
51/// Stable API — log-safe labels for connection endpoints and other local
52/// diagnostics that should be correlated without exposing raw backend hosts.
53pub mod log_redact;
54
55/// Internal shared API — secure audit JSONL writer used by in-repo crates.
56///
57/// This is public to avoid duplicating 0700/0600 audit log permission handling
58/// between `futu-core::log` and `futu-auth::audit`; external callers should use
59/// their higher-level logging/auth entrypoints.
60pub mod audit_log_writer;
61
62/// Stable API — 市场 enum 与时区 dispatch(v1.4.69 跨 crate 共享)。
63/// futu-gateway handlers / bridge / qot util 用。
64pub mod market;
65
66/// Stable API — trade-side market id namespace wrappers.
67/// Used by `futu-trd`, trade domain crates, and gateway adapters to avoid
68/// raw/canonical fund-market drift.
69pub mod trade_market;
70
71/// Stable API — trade-side user-facing raw enum parsers.
72pub mod trade_parsing;
73
74/// Stable API — trade-side security code shape and sec-market derivation.
75/// Used by `futu-trd` and trade-write domain without introducing reverse
76/// runtime/domain dependencies.
77pub mod trade_security;
78
79/// Stable API — trade-side broker identity mapping shared by routing and
80/// combo-order adapters.
81pub mod trade_broker;
82
83/// Stable API — trade-side currency labels and shared user-facing diagnostics.
84pub mod trade_currency;
85
86/// Stable API — C++ language-pack compatible text lookup.
87///
88/// Used by public API handlers that receive `FTStringDefine.StringID` from
89/// backend protocols and must project it to the same user-visible string as
90/// C++ OpenD.
91pub mod localization;
92
93/// Stable API — `ExchType` enum → exchange code 字符串(v1.4.93 跨 crate 共享)。
94/// REST adapter / futucli / MCP / qot SDK 用. 对齐 `proto/Qot_Common.proto::ExchType`.
95pub mod exch_type;
96
97/// Stable API — 账户定位纯规则(acc_id / card_num / uni_card_num)。
98/// Surface 只能调用这些规则,不应各自手写 4 位卡号、16 位卡号、白名单和可见
99/// 卡号匹配语义。
100pub mod account_locator;
101
102/// Internal shared API — ConnIP backend result-code policy used by platform
103/// and broker UpdateConnIp responses.
104pub mod conn_ip;
105
106/// Internal shared API — CMD9419/CMD20176 broker-discovery ret-code policy.
107pub mod broker_discovery;
108
109/// Stable API — operator-facing capability/readiness diagnostic decision rows.
110/// Used by quote-rights, static-status, doctor, and future diagnostics to keep
111/// `reason` / `action` / `source` / `freshness` contracts consistent.
112pub mod diagnostic;
113
114/// Stable API — user-facing diagnostic hint text with machine-readable keys.
115/// Used by CLI / REST / MCP / gateway surfaces so action hints do not drift.
116pub mod diagnostic_text;
117
118/// **Stable** (v1.4.110) — QOT broker-aware stock/security key.
119///
120/// 用于 SubscriptionManager / QotCache / push registry / GetSubInfo 全栈对齐
121/// C++ `StockKey(stock_id, broker_id)`. 数字货币 multi-broker 场景下让同一
122/// stock_id 的不同 broker 订阅独立隔离, 避免 push 混投 + cache 互相覆盖.
123///
124/// 跨 crate 消费者: futu-server (SubscriptionManager) / futu-cache (QotCache) /
125/// futu-gateway-qot (15 behavior-aware handler) / futu-backend (CMD6211 wire).
126pub mod qot_stock_key;
127
128/// Stable API — pure QOT MARKET.CODE symbol parsing and formatting rules.
129pub mod qot_symbol;
130
131/// Stable API — proto-free QOT list input validation and stock-id resolution rules.
132pub mod qot_symbol_list;
133
134/// Stable API — pure QOT pagination and max-count validation rules.
135pub mod qot_page_bounds;
136
137/// Stable API — QOT subscribe/session option normalization shared by SDK and surfaces.
138pub mod qot_subscription_options;
139
140/// Stable API — QOT read/subscribe permission gate contract shared by SDK and surfaces.
141pub mod qot_right_gate;
142
143/// Stable API — QOT quote-rights diagnostic DTOs and profile projection.
144pub mod qot_quote_rights;
145
146/// Stable API — QOT subscription public constants and backend route DTOs.
147pub mod qot_subscription;
148
149/// Stable API — QOT price-reminder endpoint-local market buckets.
150pub mod qot_price_reminder;
151
152/// Stable API — QOT StockFilter/IPO endpoint-local market buckets.
153pub mod qot_endpoint_market;
154
155/// Stable API — QOT PlateSet endpoint-local market buckets.
156pub mod qot_plate_market;
157
158/// Stable API — QOT trading-days `TradeDateMarket` enum and legacy aliases.
159pub mod qot_trade_date_market;
160
161/// Stable API — FutuOpenD API 协议 ID 常量(对齐 C++ `FTAPI_Define_ProtoID.h`)。
162/// 所有 network / handler / test 代码用。
163pub mod proto_id;
164
165/// Internal shared API — C++ `INNData_ProtoDelay`-style local delay statistics.
166///
167/// This lives in `futu-core` so public TCP surfaces and backend request paths
168/// can record into one process-wide store without forcing lower-level network
169/// crates to depend on `futu-backend`.
170pub mod delay_stats;