mtgjson/files/
all_printings.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::{meta::Meta, set::Set};
6
7/// Every printing of every card, grouped by set.
8#[derive(Debug, Clone, Serialize, Deserialize)]
9#[serde(rename_all = "camelCase")]
10pub struct AllPrintings {
11    /// Metadata about the data set.
12    pub meta: Meta,
13
14    /// Sets grouped by name.
15    pub data: HashMap<String, Set>,
16}
17
18#[cfg(test)]
19mod tests {
20    use super::*;
21    use std::fs::File;
22    use std::io::BufReader;
23
24    #[cfg_attr(not(feature = "local_tests"), ignore)]
25    #[test]
26    fn test_all_printings_local() {
27        let file = File::open("testdata/AllPrintings.json").unwrap();
28        let reader = BufReader::new(file);
29        let _: AllPrintings = serde_json::from_reader(reader).unwrap();
30    }
31
32    #[cfg_attr(not(feature = "network_tests"), ignore)]
33    #[test]
34    fn test_all_printings_network() {
35        let _: AllPrintings =
36            reqwest::blocking::get("https://mtgjson.com/api/v5/AllPrintings.json")
37                .unwrap()
38                .json()
39                .unwrap();
40    }
41}