barter_data/exchange/bybit/
channel.rs

1use crate::{
2    Identifier,
3    exchange::bybit::Bybit,
4    subscription::{Subscription, trade::PublicTrades},
5};
6use serde::Serialize;
7
8/// Type that defines how to translate a Barter [`Subscription`] into a [`Bybit`]
9/// channel to be subscribed to.
10///
11/// See docs: <https://bybit-exchange.github.io/docs/v5/ws/connect>
12#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize)]
13pub struct BybitChannel(pub &'static str);
14
15impl BybitChannel {
16    /// [`Bybit`] real-time trades channel name.
17    ///
18    /// See docs: <https://bybit-exchange.github.io/docs/v5/websocket/public/trade>
19    pub const TRADES: Self = Self("publicTrade");
20}
21
22impl<Server, Instrument> Identifier<BybitChannel>
23    for Subscription<Bybit<Server>, Instrument, PublicTrades>
24{
25    fn id(&self) -> BybitChannel {
26        BybitChannel::TRADES
27    }
28}
29
30impl AsRef<str> for BybitChannel {
31    fn as_ref(&self) -> &str {
32        self.0
33    }
34}