Skip to main content

finance_query/coingecko/
models.rs

1//! CoinGecko data models.
2
3use serde::{Deserialize, Serialize};
4
5/// A cryptocurrency quote from CoinGecko.
6///
7/// Obtain via [`super::coins`] or [`super::coin`].
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[non_exhaustive]
10pub struct CoinQuote {
11    /// CoinGecko coin ID (e.g., `"bitcoin"`, `"ethereum"`)
12    pub id: String,
13    /// Ticker symbol in uppercase (e.g., `"BTC"`, `"ETH"`)
14    pub symbol: String,
15    /// Full coin name (e.g., `"Bitcoin"`)
16    pub name: String,
17    /// Current price in the requested currency
18    pub current_price: Option<f64>,
19    /// Market capitalisation
20    pub market_cap: Option<f64>,
21    /// 24-hour price change percentage
22    pub price_change_percentage_24h: Option<f64>,
23    /// 24-hour trading volume
24    pub total_volume: Option<f64>,
25    /// Circulating supply
26    pub circulating_supply: Option<f64>,
27    /// URL to the coin's logo image
28    pub image: Option<String>,
29    /// Market cap rank (1 = highest market cap)
30    pub market_cap_rank: Option<u32>,
31}