barter_data/exchange/okx/
channel.rs

1use super::Okx;
2use crate::{
3    Identifier,
4    subscription::{Subscription, trade::PublicTrades},
5};
6use serde::Serialize;
7
8/// Type that defines how to translate a Barter [`Subscription`] into a
9/// [`Okx`] channel to be subscribed to.
10///
11/// See docs: <https://www.okx.com/docs-v5/en/#websocket-api-public-channel>
12#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
13pub struct OkxChannel(pub &'static str);
14
15impl OkxChannel {
16    /// [`Okx`] real-time trades channel.
17    ///
18    /// See docs: <https://www.okx.com/docs-v5/en/#websocket-api-public-channel-trades-channel>
19    pub const TRADES: Self = Self("trades");
20}
21
22impl<Instrument> Identifier<OkxChannel> for Subscription<Okx, Instrument, PublicTrades> {
23    fn id(&self) -> OkxChannel {
24        OkxChannel::TRADES
25    }
26}
27
28impl AsRef<str> for OkxChannel {
29    fn as_ref(&self) -> &str {
30        self.0
31    }
32}