rust_okx/ws/response/push.rs
1//! Generic channel data-push response envelope.
2
3use serde::Deserialize;
4
5use crate::ws::Arg;
6
7use super::ResponseExtraFields;
8
9/// Generic channel data-push response body.
10///
11/// `T` is the channel row type from [`crate::ws::model`].
12///
13/// OKX docs: <https://www.okx.com/docs-v5/en/#overview-websocket-subscribe>
14#[derive(Debug, Clone, Deserialize)]
15#[serde(rename_all = "camelCase")]
16#[non_exhaustive]
17pub struct PushResponse<T> {
18 /// Subscription argument identifying the channel and filters.
19 pub arg: Arg,
20 /// Push action, commonly `snapshot` or `update`.
21 ///
22 /// Used by most channels. For the `positions` channel OKX uses
23 /// [`Self::event_type`] instead.
24 #[serde(default)]
25 pub action: String,
26 /// Event type used by the `positions` channel.
27 ///
28 /// Values: `snapshot` (initial / regular snapshot push) or
29 /// `event_update` (event-driven update). Empty string for channels
30 /// that use [`Self::action`] instead.
31 #[serde(default)]
32 pub event_type: String,
33 /// Current page number for paginated snapshot pushes.
34 ///
35 /// Only present on `positions` snapshot events (`eventType = "snapshot"`).
36 #[serde(default)]
37 pub cur_page: Option<u32>,
38 /// Whether this is the last page of a paginated snapshot push.
39 ///
40 /// Only present on `positions` snapshot events (`eventType = "snapshot"`).
41 #[serde(default)]
42 pub last_page: Option<bool>,
43 /// Typed channel rows.
44 #[serde(default)]
45 pub data: Vec<T>,
46 /// Fields introduced by OKX after this crate version.
47 #[serde(flatten, default)]
48 pub extra: ResponseExtraFields,
49}