Skip to main content

futu_core/
handler.rs

1use async_trait::async_trait;
2
3/// **Internal API — do not depend on stability.**
4///
5/// FutuOpenD 连接事件回调 trait,定义连接生命周期事件和服务端推送回调。
6///
7/// v1.4.89 API audit:grep 全仓库发现当前**没有任何 implementor**(futu-net /
8/// futu-server / futu-gateway 都没 impl),仅 `plans/archive/` 旧设计文档里
9/// 提到。保留该 trait 占位是为了**未来 SDK 抽象**(若把 backend connection
10/// 拆出独立 crate 供第三方使用时直接沿用)。
11///
12/// 下版若仍无 implementor,可能:
13/// - 改 gate 为 `pub(crate)` 或删除(若确认不需要 SDK 抽象)
14/// - 或移动到 `futu-net` 作为连接层内部 trait
15///
16/// 新外部依赖请先 consult maintainer。
17#[async_trait]
18pub trait FutuHandler: Send + Sync + 'static {
19    /// 连接成功回调
20    async fn on_connected(&self, conn_id: u64);
21
22    /// 断开连接回调
23    async fn on_disconnected(&self, conn_id: u64, reason: &str);
24
25    /// 接收到服务端推送
26    async fn on_push(&self, proto_id: u32, payload: &[u8]) -> crate::error::Result<()>;
27}