barter_data/exchange/bybit/
channel.rs1use crate::{
2 Identifier,
3 exchange::bybit::Bybit,
4 subscription::{
5 Subscription,
6 book::{OrderBooksL1, OrderBooksL2},
7 trade::PublicTrades,
8 },
9};
10use serde::Serialize;
11
12#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
17pub struct BybitChannel(pub &'static str);
18
19impl BybitChannel {
20 pub const TRADES: Self = Self("publicTrade");
24
25 pub const ORDER_BOOK_L1: Self = Self("orderbook.1");
29
30 pub const ORDER_BOOK_L2: Self = Self("orderbook.50");
34}
35
36impl<Server, Instrument> Identifier<BybitChannel>
37 for Subscription<Bybit<Server>, Instrument, PublicTrades>
38{
39 fn id(&self) -> BybitChannel {
40 BybitChannel::TRADES
41 }
42}
43
44impl<Server, Instrument> Identifier<BybitChannel>
45 for Subscription<Bybit<Server>, Instrument, OrderBooksL1>
46{
47 fn id(&self) -> BybitChannel {
48 BybitChannel::ORDER_BOOK_L1
49 }
50}
51
52impl<Server, Instrument> Identifier<BybitChannel>
53 for Subscription<Bybit<Server>, Instrument, OrderBooksL2>
54{
55 fn id(&self) -> BybitChannel {
56 BybitChannel::ORDER_BOOK_L2
57 }
58}
59
60impl AsRef<str> for BybitChannel {
61 fn as_ref(&self) -> &str {
62 self.0
63 }
64}