From 6d21f5e4965c971d5e41a467ac379948152d09d6 Mon Sep 17 00:00:00 2001 From: Arthur Roberts Date: Thu, 14 Aug 2025 23:44:08 +0100 Subject: [PATCH] Added checking for the correct type --- scryfall_deser/src/lib.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/scryfall_deser/src/lib.rs b/scryfall_deser/src/lib.rs index c15a303..880b25c 100644 --- a/scryfall_deser/src/lib.rs +++ b/scryfall_deser/src/lib.rs @@ -1,5 +1,5 @@ use chrono::NaiveDate; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use serde_json::Value; use std::fs; use std::io::{Read, Seek, SeekFrom, Write}; @@ -30,7 +30,7 @@ struct ScryfallBulk { pub data: Vec, } -#[derive(Deserialize, PartialEq, Debug)] +#[derive(Deserialize, Serialize, PartialEq, Debug)] pub enum ScryfallBulkType { #[serde(rename = "oracle_cards")] OracleCards, @@ -47,7 +47,7 @@ pub enum ScryfallBulkType { const SCRYFALL_BULK_API: &str = "https://api.scryfall.com/bulk-data"; pub fn download_latest( - _stype: ScryfallBulkType, + stype: ScryfallBulkType, mut dest_file: &NamedTempFile, ) -> Result<(), Box> { let bulk_body: ScryfallBulk = ureq::get(SCRYFALL_BULK_API) @@ -59,13 +59,11 @@ pub fn download_latest( let mut download_uri = String::new(); for scryfall_bulk in bulk_body.data { - // TODO: Actually implement getting different types - if scryfall_bulk.stype == "oracle_cards" { + if serde_json::to_string(&stype).unwrap() == scryfall_bulk.stype { download_uri = scryfall_bulk.download_uri; } } assert!(!download_uri.is_empty()); - let cards_response = ureq::get(download_uri) .header("User-Agent", "Arthur's Card Finger Testing v0.1") .header("Accept", "application/json")