barter_data/exchange/bitmex/
channel.rs

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