price_adapter/types/
response.rs

1use core::fmt;
2use serde::{Deserialize, Serialize};
3use serde_json::Value;
4
5/// Represents information about the price of a symbol.
6///
7/// This struct is used to store details about the price of a symbol,
8/// including the symbol name, the price value, and the timestamp.
9#[derive(Clone, Debug, Serialize, Deserialize)]
10pub struct PriceInfo {
11    pub symbol: String,
12    pub price: f64,
13    pub timestamp: u64,
14}
15
16impl fmt::Display for PriceInfo {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        write!(
19            f,
20            "PriceInfo {{ symbol: {}, price: {}, timestamp: {} }}",
21            self.symbol, self.price, self.timestamp
22        )
23    }
24}
25
26/// Represents the response structure for setting-related data.
27///
28/// This struct is used to deserialize JSON responses containing
29/// setting-related information.
30#[derive(Debug, Deserialize)]
31pub struct SettingResponse {
32    pub data: Value,
33}
34
35/// Represents different types of messages received over a WebSocket connection.
36///
37/// This enum encapsulates various types of messages that can be received
38/// over a WebSocket connection, such as price information or setting responses.
39#[derive(Debug)]
40pub enum WebsocketMessage {
41    /// Represents a message containing price information.
42    PriceInfo(PriceInfo),
43
44    /// Represents a message containing setting-related data.
45    SettingResponse(SettingResponse),
46}