Skip to main content

futu_backend/
command_runtime.rs

1//! Compatibility exports and backend transport adapter for `futu-command-runtime`.
2//!
3//! Pure command execution contracts live in `futu-command-runtime`; this module
4//! keeps the stable `futu_backend::command_runtime` import path and wires the
5//! production backend connection into the new transport trait.
6
7use async_trait::async_trait;
8use futu_command_runtime::{CommandRequest, CommandResponse, CommandTransport};
9use futu_core::error::FutuError;
10
11use crate::conn::BackendConn;
12
13pub use futu_command_runtime::{
14    CommandExecution, CommandExecutionContext, CommandExecutionOutcome, CommandOutcome,
15    CommandRuntime, CommandRuntimeAction, CommandRuntimeDecision, CommandRuntimeError,
16    decide_command_outcome,
17};
18
19#[async_trait]
20impl CommandTransport for BackendConn {
21    async fn execute(&self, request: CommandRequest) -> Result<CommandResponse, FutuError> {
22        let frame = self
23            .request_with_reserved(request.cmd_id, request.body.to_vec(), request.reserved)
24            .await?;
25        Ok(CommandResponse {
26            cmd_id: frame.header.cmd_id,
27            body: frame.body,
28            ex_head: frame.ex_head,
29        })
30    }
31}