barter_data/exchange/gateio/
channel.rs1use crate::{
2 Identifier,
3 instrument::InstrumentData,
4 subscription::{Subscription, trade::PublicTrades},
5};
6use barter_instrument::instrument::market_data::kind::MarketDataInstrumentKind;
7use serde::Serialize;
8
9#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
14pub struct GateioChannel(pub &'static str);
15
16impl GateioChannel {
17 pub const SPOT_TRADES: Self = Self("spot.trades");
21
22 pub const FUTURE_TRADES: Self = Self("futures.trades");
27
28 pub const OPTION_TRADES: Self = Self("options.trades");
32}
33
34impl<GateioExchange, Instrument> Identifier<GateioChannel>
35 for Subscription<GateioExchange, Instrument, PublicTrades>
36where
37 Instrument: InstrumentData,
38{
39 fn id(&self) -> GateioChannel {
40 match self.instrument.kind() {
41 MarketDataInstrumentKind::Spot => GateioChannel::SPOT_TRADES,
42 MarketDataInstrumentKind::Future { .. } | MarketDataInstrumentKind::Perpetual => {
43 GateioChannel::FUTURE_TRADES
44 }
45 MarketDataInstrumentKind::Option { .. } => GateioChannel::OPTION_TRADES,
46 }
47 }
48}
49
50impl AsRef<str> for GateioChannel {
51 fn as_ref(&self) -> &str {
52 self.0
53 }
54}