Half of ScryfallDeser fields added

Very non-atomic - and I'm not even sure if it's half.

I think I might stop here and actually try the derserialisation stuff
This commit is contained in:
2025-01-31 23:20:24 +00:00
parent 82255d311d
commit 9771a905ff
3 changed files with 107 additions and 0 deletions

84
scryfall_deser/src/lib.rs Normal file
View File

@@ -0,0 +1,84 @@
use serde::Deserialize;
// Info from here:
// https://scryfall.com/docs/api/cards
#[derive(Deserialize)]
struct ScryfallCard {
// Core Card Fields
pub arena_id: Option<u64>,
pub id: String, // UUID - internal for Scryfall
pub lang: String,
pub mtgo: Option<u64>,
pub mtgo_foil_id: Option<u64>,
pub multiverse_ids: Option<Vec<u64>>,
pub tcgplayer_id: Option<u64>,
pub tcgplayer_etched_id: Option<u64>,
pub cardmarket_id: Option<u64>,
pub object: String,
pub layout: String, // Perhaps some kind of enum of these: https://scryfall.com/docs/api/layouts?
pub oracle_id: Option<String>, // UUID
pub prints_search_uri: String, // URI
pub rulings_uri: String, // URI
pub scryfall_uri: String, // URI
pub uri: String, //URI
// Gameplay Fields
pub all_parts: Option<Vec<ScryfallRelatedCardObject>>,
}
// https://scryfall.com/docs/api/cards#card-face-objects
#[derive(Deserialize)]
struct ScryfallCardFaceObject {
pub artist: Option<String>,
pub artist_id: Option<String>, // UUID
pub cmc: Option<f64>, // TODO: Make this a proper Decimal - see "Little Girl" card for example of cmc of 0.5
pub colour_identity: Vec<Colour>,
pub colour_indicator: Option<Vec<Colour>>,
pub colours: Option<Vec<Colour>>,
pub defence: Option<String>,
pub edhrec_rank: Option<u64>,
}
// https://scryfall.com/docs/api/cards#related-card-objects
#[derive(Deserialize)]
struct ScryfallRelatedCardObject {
pub id: String, // UUID
pub object: String, // Always "related_card"
pub component: String, // One of token, meld_part, meld_result, combo_piece
pub name: String,
pub type_line: String,
pub uri: String // URI
}
#[derive(Deserialize, PartialEq)]
enum Colour {
White,
Blue,
Black,
Red,
Green,
Colourless
}
pub fn deserialise_card(data: String) -> Card {
Card
}
pub fn add(left: usize, right: usize) -> usize {
left + right
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}