use crate::{
Identifier,
exchange::bybit::Bybit,
subscription::{
Subscription,
book::{OrderBooksL1, OrderBooksL2},
trade::PublicTrades,
},
};
use serde::Serialize;
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
pub struct BybitChannel(pub &'static str);
impl BybitChannel {
pub const TRADES: Self = Self("publicTrade");
pub const ORDER_BOOK_L1: Self = Self("orderbook.1");
pub const ORDER_BOOK_L2: Self = Self("orderbook.50");
}
impl<Server, Instrument> Identifier<BybitChannel>
for Subscription<Bybit<Server>, Instrument, PublicTrades>
{
fn id(&self) -> BybitChannel {
BybitChannel::TRADES
}
}
impl<Server, Instrument> Identifier<BybitChannel>
for Subscription<Bybit<Server>, Instrument, OrderBooksL1>
{
fn id(&self) -> BybitChannel {
BybitChannel::ORDER_BOOK_L1
}
}
impl<Server, Instrument> Identifier<BybitChannel>
for Subscription<Bybit<Server>, Instrument, OrderBooksL2>
{
fn id(&self) -> BybitChannel {
BybitChannel::ORDER_BOOK_L2
}
}
impl AsRef<str> for BybitChannel {
fn as_ref(&self) -> &str {
self.0
}
}