diff --git a/scryfall_deser/.gitignore b/scryfall_deser/.gitignore new file mode 100644 index 0000000..6985cf1 --- /dev/null +++ b/scryfall_deser/.gitignore @@ -0,0 +1,14 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb diff --git a/scryfall_deser/Cargo.toml b/scryfall_deser/Cargo.toml new file mode 100644 index 0000000..257a929 --- /dev/null +++ b/scryfall_deser/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "scryfall_deser" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +serde = { version = "1.0", features = ["derive"] } diff --git a/scryfall_deser/src/lib.rs b/scryfall_deser/src/lib.rs new file mode 100644 index 0000000..fad4c6c --- /dev/null +++ b/scryfall_deser/src/lib.rs @@ -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, + pub id: String, // UUID - internal for Scryfall + pub lang: String, + pub mtgo: Option, + pub mtgo_foil_id: Option, + pub multiverse_ids: Option>, + pub tcgplayer_id: Option, + pub tcgplayer_etched_id: Option, + pub cardmarket_id: Option, + pub object: String, + pub layout: String, // Perhaps some kind of enum of these: https://scryfall.com/docs/api/layouts? + pub oracle_id: Option, // 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>, + + +} + + +// https://scryfall.com/docs/api/cards#card-face-objects +#[derive(Deserialize)] +struct ScryfallCardFaceObject { + pub artist: Option, + pub artist_id: Option, // UUID + pub cmc: Option, // TODO: Make this a proper Decimal - see "Little Girl" card for example of cmc of 0.5 + pub colour_identity: Vec, + pub colour_indicator: Option>, + pub colours: Option>, + pub defence: Option, + pub edhrec_rank: Option, +} + +// 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); + } +}