cmc/api/fiat/
id_map.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use std::fmt::{Display, Formatter};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
6pub struct CmcFiatIdMap {
7    pub status: Status,
8    pub data: Vec<Currency>,
9}
10
11#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
12pub struct Status {
13    pub timestamp: String,
14    pub error_code: i64,
15    pub error_message: Value,
16    pub elapsed: i64,
17    pub credit_count: i64,
18    pub notice: Value,
19}
20
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub struct Currency {
23    pub id: i64,
24    pub name: String,
25    pub sign: String,
26    pub symbol: String,
27}
28
29impl Display for CmcFiatIdMap {
30    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
31        for fc in &self.data {
32            let _ = writeln!(
33                f,
34                "Id: {}\nName: {}\nSign: {}\nSymbol: {}\n---------------",
35                fc.id, fc.name, fc.sign, fc.symbol
36            );
37        }
38        Ok(())
39    }
40}