bulk_client/api/parts/command.rs
1// ═════════════════════════════════════════════════════════════════════════════
2// Commands (client handle → actor)
3// ═════════════════════════════════════════════════════════════════════════════
4
5use tokio::sync::oneshot;
6use crate::api::parts::{Event};
7use crate::msgs::account::OrderState;
8use crate::msgs::responses::Response;
9use crate::msgs::subscription::SubscriptionRequest;
10
11/// User-supplied callback. Receives the raw JSON payload for the topic.
12/// Runs synchronously inside the actor loop — keep it fast or spawn.
13#[allow(unused)]
14type EventHandler = Box<dyn Fn(&Event) + Send + Sync>;
15
16#[allow(unused)]
17pub(crate) enum Command {
18 /// Subscribe to additional topics.
19 Subscribe(Vec<SubscriptionRequest>),
20
21 /// Send a signed order/cancel payload through the WebSocket
22 /// and wait for the post response.
23 Tx {
24 request_id: u64,
25 json: String,
26 respond: oneshot::Sender<eyre::Result<Vec<Response>>>,
27 },
28
29 /// Send a signed async payload through the WebSocket
30 /// with no wait for the post response.
31 AsyncTx {
32 json: String,
33 },
34
35 /// Send a raw JSON message (e.g. oracle update, fire-and-forget).
36 SendRaw(String),
37
38 /// Query open orders (cold path — goes through actor).
39 GetOrders {
40 symbol: Option<String>,
41 respond: oneshot::Sender<Vec<OrderState>>,
42 },
43
44 /// Graceful shutdown.
45 Shutdown,
46}