bothan_okx/api/types/
channel.rs

1//! Types for OKX WebSocket channel data.
2//!
3//! This module provides types for handling channel-based data from the OKX WebSocket API,
4//! including push data structures and channel arguments. These types are used for
5//! processing real-time market data updates from subscribed channels.
6//!
7//! # Key Types
8//!
9//! - [`PushData<T>`] - Generic container for channel push data
10//! - [`ChannelArgument`] - Channel identification and metadata
11
12use serde::{Deserialize, Serialize};
13
14/// Represents push data from a channel.
15///
16/// This generic struct contains data received from a subscribed OKX WebSocket channel.
17/// It includes both the channel metadata (`arg`) and the actual data payload (`data`).
18#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
19pub struct PushData<T> {
20    /// The argument for the channel containing metadata.
21    pub arg: ChannelArgument,
22
23    /// The data received from the channel.
24    pub data: T,
25}
26
27/// Represents the argument for a channel.
28///
29/// This struct contains metadata about a WebSocket channel, including the channel name
30/// and the specific instrument being monitored. It's used to identify the source and
31/// context of incoming data.
32#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct ChannelArgument {
35    /// The name of the channel (e.g., "tickers", "trades", "books").
36    pub channel: String,
37
38    /// The instrument ID being monitored (e.g., "BTC-USDT").
39    pub inst_id: String,
40}