deribit_websocket/
subscriptions.rs

1//! WebSocket subscription management
2
3use std::fmt;
4
5/// Subscription channels
6#[derive(Debug, Clone)]
7pub enum SubscriptionChannel {
8    /// Ticker data for a specific instrument
9    Ticker(String),
10    /// Order book data for a specific instrument
11    OrderBook(String),
12    /// Trade data for a specific instrument
13    Trades(String),
14    /// User's order updates
15    UserOrders,
16    /// User's trade updates
17    UserTrades,
18}
19
20impl fmt::Display for SubscriptionChannel {
21    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
22        let channel_str = match self {
23            Self::Ticker(instrument) => format!("ticker.{instrument}.raw"),
24            Self::OrderBook(instrument) => format!("book.{instrument}.raw"),
25            Self::Trades(instrument) => format!("trades.{instrument}.raw"),
26            Self::UserOrders => "user.orders.any.any.raw".to_string(),
27            Self::UserTrades => "user.trades.any.any.raw".to_string(),
28        };
29        write!(f, "{channel_str}")
30    }
31}