barter_data/exchange/bitfinex/
channel.rs

1use super::Bitfinex;
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/// [`Bitfinex`] channel to be subscribed to.
10///
11/// See docs: <https://docs.bitfinex.com/docs/ws-public>
12#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
13pub struct BitfinexChannel(pub &'static str);
14
15impl BitfinexChannel {
16    /// [`Bitfinex`] real-time trades channel.
17    ///
18    /// See docs: <https://docs.bitfinex.com/reference/ws-public-trades>
19    pub const TRADES: Self = Self("trades");
20}
21
22impl<Instrument> Identifier<BitfinexChannel> for Subscription<Bitfinex, Instrument, PublicTrades> {
23    fn id(&self) -> BitfinexChannel {
24        BitfinexChannel::TRADES
25    }
26}
27
28impl AsRef<str> for BitfinexChannel {
29    fn as_ref(&self) -> &str {
30        self.0
31    }
32}