use crate::{
Identifier,
instrument::InstrumentData,
subscription::{Subscription, trade::PublicTrades},
};
use barter_instrument::instrument::market_data::kind::MarketDataInstrumentKind;
use serde::Serialize;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
pub struct GateioChannel(pub &'static str);
impl GateioChannel {
pub const SPOT_TRADES: Self = Self("spot.trades");
pub const FUTURE_TRADES: Self = Self("futures.trades");
pub const OPTION_TRADES: Self = Self("options.trades");
}
impl<GateioExchange, Instrument> Identifier<GateioChannel>
for Subscription<GateioExchange, Instrument, PublicTrades>
where
Instrument: InstrumentData,
{
fn id(&self) -> GateioChannel {
match self.instrument.kind() {
MarketDataInstrumentKind::Spot => GateioChannel::SPOT_TRADES,
MarketDataInstrumentKind::Future { .. } | MarketDataInstrumentKind::Perpetual => {
GateioChannel::FUTURE_TRADES
}
MarketDataInstrumentKind::Option { .. } => GateioChannel::OPTION_TRADES,
}
}
}
impl AsRef<str> for GateioChannel {
fn as_ref(&self) -> &str {
self.0
}
}