Ran rustfmt and clippy

This commit is contained in:
2025-02-07 22:38:20 +00:00
parent a14d2dcb75
commit a1728de503

View File

@@ -1,7 +1,7 @@
use chrono::NaiveDate;
use serde::Deserialize; use serde::Deserialize;
use serde_json::Value; use serde_json::Value;
use uuid::Uuid; use uuid::Uuid;
use chrono::NaiveDate;
// Info from here: // Info from here:
// https://scryfall.com/docs/api/cards // https://scryfall.com/docs/api/cards
@@ -112,8 +112,7 @@ struct ScryfallCard {
#[serde(rename = "preview.source_uri")] #[serde(rename = "preview.source_uri")]
pub preview_source_uri: Option<String>, // URI pub preview_source_uri: Option<String>, // URI
#[serde(rename = "preview.source")] #[serde(rename = "preview.source")]
pub preview_source: Option<String> pub preview_source: Option<String>,
} }
// https://scryfall.com/docs/api/cards#card-face-objects // https://scryfall.com/docs/api/cards#card-face-objects
@@ -146,7 +145,7 @@ struct ScryfallCardFaceObject {
pub printed_type_line: Option<String>, pub printed_type_line: Option<String>,
pub toughness: Option<String>, pub toughness: Option<String>,
pub type_line: Option<String>, pub type_line: Option<String>,
pub watermark: Option<String> pub watermark: Option<String>,
} }
// https://scryfall.com/docs/api/cards#related-card-objects // https://scryfall.com/docs/api/cards#related-card-objects
@@ -158,7 +157,7 @@ struct ScryfallRelatedCardObject {
pub component: Component, pub component: Component,
pub name: String, pub name: String,
pub type_line: String, pub type_line: String,
pub uri: String // URI pub uri: String, // URI
} }
#[derive(Deserialize, PartialEq, Debug)] #[derive(Deserialize, PartialEq, Debug)]
@@ -176,7 +175,7 @@ enum Colour {
#[serde(rename = "C")] // I don't think it's meant to work like this... but eh #[serde(rename = "C")] // I don't think it's meant to work like this... but eh
Colourless, Colourless,
#[serde(rename = "T")] // See "Sole Performer" #[serde(rename = "T")] // See "Sole Performer"
Tap Tap,
} }
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]
@@ -215,7 +214,7 @@ struct FormatLegalities {
duel: Legality, duel: Legality,
oldschool: Legality, oldschool: Legality,
premodern: Legality, premodern: Legality,
predh: Legality predh: Legality,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -232,7 +231,7 @@ enum BorderColour {
#[serde(rename = "silver")] #[serde(rename = "silver")]
Silver, Silver,
#[serde(rename = "gold")] #[serde(rename = "gold")]
Gold Gold,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -243,7 +242,7 @@ enum Finish {
#[serde(rename = "nonfoil")] #[serde(rename = "nonfoil")]
NonFoil, NonFoil,
#[serde(rename = "etched")] #[serde(rename = "etched")]
Etched Etched,
} }
// https://scryfall.com/docs/api/frames#frames // https://scryfall.com/docs/api/frames#frames
@@ -260,7 +259,7 @@ enum Frame {
#[serde(rename = "2015")] #[serde(rename = "2015")]
Fifteen, Fifteen,
#[serde(rename = "future")] #[serde(rename = "future")]
Future Future,
} }
// https://scryfall.com/docs/api/frames#frame-effects // https://scryfall.com/docs/api/frames#frame-effects
@@ -316,7 +315,7 @@ enum FrameEffect {
#[serde(rename = "spree")] #[serde(rename = "spree")]
Spree, Spree,
#[serde(rename = "fullart")] #[serde(rename = "fullart")]
FullArt FullArt,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -325,13 +324,13 @@ enum Game {
#[serde(rename = "paper")] #[serde(rename = "paper")]
Paper, Paper,
#[serde(rename = "mtgo")] #[serde(rename = "mtgo")]
MTGO, Mtgo,
#[serde(rename = "arena")] #[serde(rename = "arena")]
Arena, Arena,
#[serde(rename = "astral")] #[serde(rename = "astral")]
Astral, Astral,
#[serde(rename = "sega")] #[serde(rename = "sega")]
Sega Sega,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -344,7 +343,7 @@ enum ImageStatus {
#[serde(rename = "lowres")] #[serde(rename = "lowres")]
LowResolution, LowResolution,
#[serde(rename = "highres_scan")] #[serde(rename = "highres_scan")]
HighResolutionScan HighResolutionScan,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -355,7 +354,7 @@ struct ImageURIs {
art_crop: Option<String>, art_crop: Option<String>,
large: Option<String>, large: Option<String>,
normal: Option<String>, normal: Option<String>,
small: Option<String> small: Option<String>,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -366,7 +365,7 @@ struct Prices {
usd_etched: Option<String>, usd_etched: Option<String>,
eur: Option<String>, eur: Option<String>,
eur_foil: Option<String>, eur_foil: Option<String>,
tix: Option<String> tix: Option<String>,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -383,7 +382,7 @@ enum Rarity {
#[serde(rename = "mythic")] #[serde(rename = "mythic")]
Mythic, Mythic,
#[serde(rename = "bonus")] #[serde(rename = "bonus")]
Bonus Bonus,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -408,7 +407,7 @@ enum SecurityStamp {
#[serde(rename = "arena")] #[serde(rename = "arena")]
Arena, Arena,
#[serde(rename = "heart")] #[serde(rename = "heart")]
Heart Heart,
} }
#[allow(dead_code)] #[allow(dead_code)]
@@ -427,9 +426,9 @@ enum Component {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
use std::path::PathBuf;
use std::fs; use std::fs;
use std::io::{BufRead, BufReader}; use std::io::{BufRead, BufReader};
use std::path::PathBuf;
#[test] #[test]
fn deserialise_nissa() { fn deserialise_nissa() {
@@ -475,17 +474,16 @@ mod tests {
line.push('}'); line.push('}');
} }
if line.len() < 1 { continue }; if line.is_empty() {
let a_card: Result<ScryfallCard, serde_json::Error> = serde_json::from_str(&line.as_ref()); continue;
match a_card { };
Err(error) => { let a_card: Result<ScryfallCard, serde_json::Error> =
serde_json::from_str(line.as_ref());
if let Err(error) = a_card {
println!("{:#?}", line); println!("{:#?}", line);
println!("{:#?}", error); println!("{:#?}", error);
panic!(); panic!();
}, }
Ok(_) => (),
}
} }
} }
} }