ccxt_core/ws_client/message.rs
1//! WebSocket message types.
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5use std::collections::HashMap;
6
7/// WebSocket message types for exchange communication.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(tag = "type", rename_all = "lowercase")]
10pub enum WsMessage {
11 /// Subscribe to a channel
12 Subscribe {
13 /// Channel name
14 channel: String,
15 /// Optional trading pair symbol
16 symbol: Option<String>,
17 /// Additional parameters
18 params: Option<HashMap<String, Value>>,
19 },
20 /// Unsubscribe from a channel
21 Unsubscribe {
22 /// Channel name
23 channel: String,
24 /// Optional trading pair symbol
25 symbol: Option<String>,
26 },
27 /// Ping message for keepalive
28 Ping {
29 /// Timestamp in milliseconds
30 timestamp: i64,
31 },
32 /// Pong response to ping
33 Pong {
34 /// Timestamp in milliseconds
35 timestamp: i64,
36 },
37 /// Authentication message
38 Auth {
39 /// API key
40 api_key: String,
41 /// HMAC signature
42 signature: String,
43 /// Timestamp in milliseconds
44 timestamp: i64,
45 },
46 /// Custom message payload
47 Custom(Value),
48}