scryfall_sdk_rust/resources/
catalog.rs

1//! Catalog resource definitions
2//!
3//! See [Scryfall api documentation](https://scryfall.com/docs/api/catalogs)
4
5use serde::{Deserialize, Serialize};
6use url::Url;
7
8use CatalogResource::*;
9
10use crate::resources::{HttpResource, ResourceKind};
11
12/// Endpoints for `/catalog` resource
13pub enum CatalogResource {
14    /// Binding for endpoint `GET /catalog/ability-words`
15    AbilityWords,
16
17    /// Binding for endpoint `GET /catalog/artifact-types`
18    ArtifactTypes,
19
20    /// Binding for endpoint `GET /catalog/artist-names`
21    ArtistNames,
22
23    /// Binding for endpoint `GET /catalog/card-names`
24    CardNames,
25
26    /// Binding for endpoint `GET /catalog/creature-types`
27    CreatureTypes,
28
29    /// Binding for endpoint `GET /catalog/enchantment-types`
30    EnchantmentTypes,
31
32    /// Binding for endpoint `GET /catalog/keyword-abilities`
33    KeywordAbilities,
34
35    /// Binding for endpoint `GET /catalog/keyword-actions`
36    KeywordActions,
37
38    /// Binding for endpoint `GET /catalog/land-types`
39    LandTypes,
40
41    /// Binding for endpoint `GET /catalog/loyalties`
42    Loyalties,
43
44    /// Binding for endpoint `GET /catalog/planeswalker-types`
45    PlaneswalkerTypes,
46
47    /// Binding for endpoint `GET /catalog/powers`
48    Powers,
49
50    /// Binding for endpoint `GET /catalog/spell-types`
51    SpellTypes,
52
53    /// Binding for endpoint `GET /catalog/toughnesses`
54    Toughnesses,
55
56    /// Binding for endpoint `GET /catalog/watermarks`
57    Watermarks,
58
59    /// Binding for endpoint `GET /catalog/word-bank`
60    WordBank,
61}
62
63impl HttpResource<Catalog> for CatalogResource {
64    fn path(&self) -> String {
65        format!("catalog/{}", match self {
66            AbilityWords => "ability-words",
67            ArtifactTypes => "artifact-types",
68            ArtistNames => "artist-names",
69            CardNames => "card-names",
70            CreatureTypes => "creature-types",
71            EnchantmentTypes => "enchantment-types",
72            KeywordAbilities => "keyword-abilities",
73            KeywordActions => "keyword-actions",
74            LandTypes => "land-types",
75            Loyalties => "loyalties",
76            PlaneswalkerTypes => "planeswalker-types",
77            Powers => "powers",
78            SpellTypes => "spell-types",
79            Toughnesses => "toughnesses",
80            Watermarks => "watermarks",
81            WordBank => "word-bank",
82        })
83    }
84}
85
86/// Basic struct representing a catalog
87#[derive(Serialize, Deserialize, Debug, PartialEq)]
88pub struct Catalog {
89    #[serde(rename = "object")]
90    pub kind: ResourceKind,
91    pub uri: Option<Url>,
92    pub total_values: i64,
93    pub data: Vec<String>,
94}