finance-query 3.0.0

A Rust library for querying financial data
Documentation
// @generated by `cargo soothfast docs gen-tests`
// source: docs/library/crypto.md line 88
#[cfg(feature = "crypto")]
fn main() {
    use finance_query::crypto::CoinQuote;

    // `CoinQuote` is #[non_exhaustive] outside the crate, so construct via
    // serde. With live data: `crypto::coin("bitcoin", "usd").await?`.
    let coin: CoinQuote = serde_json::from_value(serde_json::json!({
        "id": "bitcoin",
        "symbol": "BTC",
        "name": "Bitcoin",
        "current_price": 67234.50,
        "market_cap": 1_325_000_000_000.0,
        "market_cap_rank": 1,
        "price_change_percentage_24h": 2.35,
        "total_volume": 28_400_000_000.0,
        "circulating_supply": 19_700_000.0,
        "image": "https://assets.coingecko.com/coins/images/1/large/bitcoin.png",
    }))
    .unwrap();

    fn verify_coin_quote_fields(c: CoinQuote) {
        let _: String = c.id;
        let _: String = c.symbol;
        let _: String = c.name;
        let _: Option<f64> = c.current_price;
        let _: Option<f64> = c.market_cap;
        let _: Option<u32> = c.market_cap_rank;
        let _: Option<f64> = c.price_change_percentage_24h;
        let _: Option<f64> = c.total_volume;
        let _: Option<f64> = c.circulating_supply;
        let _: Option<String> = c.image;
    }
    verify_coin_quote_fields(coin.clone());

    println!("id = {}, symbol = {}", coin.id, coin.symbol);
    println!("current_price = {:?}", coin.current_price);
    println!("market_cap_rank = {:?}", coin.market_cap_rank);
}

#[cfg(not(feature = "crypto"))]
fn main() {}