finance-query 3.2.0

A Rust library for querying financial data
Documentation
// @generated by `cargo soothfast docs gen-tests`
// source: docs/library/commodities.md line 189
fn main() {
    use finance_query::CommodityQuote;

    // `CommodityQuote` is #[non_exhaustive] outside the crate, so construct via
    // serde. With live data: `commodity.quote().await?`.
    let quote: CommodityQuote = serde_json::from_value(serde_json::json!({
        "symbol": "GC=F",
        "name": "Gold",
        "unit": "troy ounce",
        "price": 2387.50,
        "change": 12.30,
        "change_percent": 0.52,
        "timestamp": 1_718_000_000_i64,
    }))
    .unwrap();

    fn verify_commodity_quote_fields(q: CommodityQuote) {
        let _: String = q.symbol;
        let _: Option<String> = q.name;
        let _: Option<String> = q.unit;
        let _: Option<f64> = q.price;
        let _: Option<f64> = q.change;
        let _: Option<f64> = q.change_percent;
        let _: Option<i64> = q.timestamp;
    }
    verify_commodity_quote_fields(quote.clone());

    println!("symbol = {}", quote.symbol);
    println!("name = {:?}", quote.name);
    println!("price = {:?}", quote.price);
}