pub struct FutuClient { /* private fields */ }Expand description
FutuOpenD 高层客户端
功能:
- InitConnect 握手
- 自动心跳 KeepAlive
- 请求-响应匹配(serial number)
- 推送消息分发
- 断线重连
Implementations§
Source§impl FutuClient
impl FutuClient
Sourcepub fn new(config: ClientConfig) -> (Self, PushReceiver)
pub fn new(config: ClientConfig) -> (Self, PushReceiver)
创建客户端(未连接状态)
返回 (client, push_rx),其中 push_rx 用于接收服务端推送。
Sourcepub fn with_init_ai_type(self, ai_type: Option<i32>) -> Self
pub fn with_init_ai_type(self, ai_type: Option<i32>) -> Self
Set C++ 10.7 InitConnect.C2S.aiType for the next connection.
None preserves the legacy wire shape. C++ treats an absent value as
0 (non-AI); Some(1) marks a skills/AI caller.
Sourcepub async fn connect(&mut self) -> Result<InitConnectInfo>
pub async fn connect(&mut self) -> Result<InitConnectInfo>
连接到 OpenD 网关并完成 InitConnect 握手
Sourcepub async fn request_with_timeout(
&self,
proto_id: u32,
body: Vec<u8>,
timeout: Duration,
) -> Result<FutuFrame>
pub async fn request_with_timeout( &self, proto_id: u32, body: Vec<u8>, timeout: Duration, ) -> Result<FutuFrame>
发送请求并等待响应(调用方可指定总请求等待上限)。
与 Self::request 共用同一 pending 清理路径:command channel 入队、
send ack、响应等待任一阶段超时时都必须移除 pending[serial],避免
调用方自己在外层 tokio::time::timeout 取消 future 时留下悬挂请求。
Auto Trait Implementations§
impl !Freeze for FutuClient
impl !RefUnwindSafe for FutuClient
impl Send for FutuClient
impl Sync for FutuClient
impl Unpin for FutuClient
impl UnsafeUnpin for FutuClient
impl !UnwindSafe for FutuClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more