Struct Card

Source
#[non_exhaustive]
pub struct Card {
Show 86 fields pub arena_id: Option<usize>, pub id: Uuid, pub lang: String, pub mtgo_id: Option<usize>, pub mtgo_foil_id: Option<usize>, pub multiverse_ids: Option<Vec<usize>>, pub tcgplayer_id: Option<usize>, pub tcgplayer_etched_id: Option<usize>, pub cardmarket_id: Option<usize>, pub oracle_id: Option<Uuid>, pub prints_search_uri: Uri<List<Card>>, pub rulings_uri: Uri<Vec<Ruling>>, pub scryfall_uri: Url, pub uri: Uri<Card>, pub all_parts: Option<Vec<RelatedCard>>, pub card_faces: Option<Vec<CardFace>>, pub cmc: Option<f32>, pub color_identity: Vec<Color>, pub color_indicator: Option<Vec<Color>>, pub colors: Option<Vec<Color>>, pub edhrec_rank: Option<usize>, pub game_changer: Option<bool>, pub foil: bool, pub hand_modifier: Option<String>, pub keywords: Vec<String>, pub layout: Layout, pub legalities: CardLegality, pub life_modifier: Option<String>, pub loyalty: Option<String>, pub mana_cost: Option<String>, pub name: String, pub nonfoil: bool, pub oracle_text: Option<String>, pub oversized: bool, pub power: Option<String>, pub produced_mana: Option<Vec<ProducedMana>>, pub reserved: bool, pub toughness: Option<String>, pub type_line: Option<String>, pub penny_rank: Option<u64>, pub defense: Option<String>, pub artist: Option<String>, pub artist_ids: Option<Vec<Uuid>>, pub booster: bool, pub border_color: BorderColor, pub card_back_id: Option<Uuid>, pub collector_number: String, pub content_warning: bool, pub digital: bool, pub flavor_name: Option<String>, pub flavor_text: Option<String>, pub frame_effects: Vec<FrameEffect>, pub frame: Frame, pub full_art: bool, pub games: Vec<Game>, pub highres_image: bool, pub illustration_id: Option<Uuid>, pub image_status: ImageStatus, pub image_uris: Option<ImageUris>, pub prices: Price, pub printed_name: Option<String>, pub printed_text: Option<String>, pub printed_type_line: Option<String>, pub promo: bool, pub purchase_uris: Option<PurchaseUris>, pub rarity: Rarity, pub related_uris: Option<RelatedUris>, pub released_at: NaiveDate, pub reprint: bool, pub scryfall_set_uri: String, pub set_name: String, pub set_search_uri: Uri<List<Card>>, pub set_type: SetType, pub set_uri: Uri<Set>, pub set: SetCode, pub set_id: Uuid, pub story_spotlight: bool, pub textless: bool, pub variation: bool, pub variation_of: Option<Uuid>, pub watermark: Option<String>, pub preview: Preview, pub finishes: Vec<Finishes>, pub security_stamp: Option<SecurityStamp>, pub promo_types: Vec<PromoType>, pub attraction_lights: Option<Vec<u8>>,
}
Expand description

Card objects represent individual Magic: The Gathering cards that players could obtain and add to their collection (with a few minor exceptions).

§Card Names

Internally, Scryfall tracks the uniqueness of “Oracle names.” (i.e. names you can pick when an effect asks you to “choose a card name”). Each unique Oracle name is separately available in the card names catalog.

Note that while most Oracle card names are unique, Scryfall also indexes other objects such as tokens and Unstable set variants which do not always have a unique name.

§Multiface Cards

Magic cards can have multiple faces. The faces could be shown divided on the front of the card as in split cards and flip cards, or the card can be double-sided as in transform cards and double-sided tokens.

Scryfall represents multiface cards as a single object with a card_faces array describing the distinct faces.


For more details, see the official documentation.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§arena_id: Option<usize>

This card’s Arena ID, if any. A large percentage of cards are not available on Arena and do not have this ID.

§id: Uuid

A unique ID for this card in Scryfall’s database.

§lang: String

A language code for this printing.

§mtgo_id: Option<usize>

This card’s Magic Online ID (also known as the Catalog ID), if any. A large percentage of cards are not available on Magic Online and do not have this ID.

§mtgo_foil_id: Option<usize>

This card’s foil Magic Online ID (also known as the Catalog ID), if any. A large percentage of cards are not available on Magic Online and do not have this ID.

§multiverse_ids: Option<Vec<usize>>

This card’s multiverse IDs on Gatherer, if any, as an array of integers. Note that Scryfall includes many promo cards, tokens, and other esoteric objects that do not have these identifiers.

§tcgplayer_id: Option<usize>

This card’s ID on TCGplayer’s API, also known as the productId.

§tcgplayer_etched_id: Option<usize>

This card’s ID on TCGplayer’s API, for its etched version if that version is a separate product.

§cardmarket_id: Option<usize>

This card’s ID on Cardmarket’s API, also known as the idProduct.

§oracle_id: Option<Uuid>

A unique ID for this card’s oracle identity. This value is consistent across reprinted card editions, and unique among different cards with the same name (tokens, Unstable variants, etc).

§prints_search_uri: Uri<List<Card>>

A link to where you can begin paginating all re/prints for this card on Scryfall’s API.

§rulings_uri: Uri<Vec<Ruling>>

A link to this card’s rulings list on Scryfall’s API.

§scryfall_uri: Url

A link to this card’s permapage on Scryfall’s website.

§uri: Uri<Card>

A link to this card object on Scryfall’s API.

§all_parts: Option<Vec<RelatedCard>>

If this card is closely related to other cards, this property will be an array with Related Card Objects.

§card_faces: Option<Vec<CardFace>>

An array of Card Face objects, if this card is multifaced.

§cmc: Option<f32>

The card’s converted mana cost. Note that some funny cards have fractional mana costs.

§color_identity: Vec<Color>

This card’s color identity.

§color_indicator: Option<Vec<Color>>

The colors in this card’s color indicator, if any. A null value for this field indicates the card does not have one.

§colors: Option<Vec<Color>>

This card’s colors, if the overall card has colors defined by the rules. Otherwise the colors will be on the card_faces objects, see below.

§edhrec_rank: Option<usize>

This card’s overall rank/popularity on EDHREC. Not all cards are ranked.

§game_changer: Option<bool>

True if this card is on the Commander Game Changer list.

§foil: bool

True if this printing exists in a foil version.

§hand_modifier: Option<String>

This card’s hand modifier, if it is Vanguard card. This value will contain a delta, such as -1.

§keywords: Vec<String>

An array of keywords that this card uses, such as ‘Flying’ and ‘Cumulative upkeep’.

§layout: Layout

A code for this card’s layout.

§legalities: CardLegality

An object describing the legality of this card across play formats. Possible legalities are legal, not_legal, restricted, and banned.

§life_modifier: Option<String>

This card’s life modifier, if it is Vanguard card. This value will contain a delta, such as +2.

§loyalty: Option<String>

This loyalty if any. Note that some cards have loyalties that are not numeric, such as X.

§mana_cost: Option<String>

The mana cost for this card. This value will be any empty string “” if the cost is absent. Remember that per the game rules, a missing mana cost and a mana cost of {0} are different values. Multi-faced cards will report this value in card faces.

§name: String

The name of this card. If this card has multiple faces, this field will contain both names separated by //.

§nonfoil: bool

True if this printing exists in a nonfoil version.

§oracle_text: Option<String>

The Oracle text for this card, if any.

§oversized: bool

True if this card is oversized.

§power: Option<String>

This card’s power, if any. Note that some cards have powers that are not numeric, such as *.

§produced_mana: Option<Vec<ProducedMana>>

Colors of mana that this card could produce.

§reserved: bool

True if this card is on the Reserved List.

§toughness: Option<String>

This card’s toughness, if any. Note that some cards have toughnesses that are not numeric, such as *.

§type_line: Option<String>

The type line of this card.

§penny_rank: Option<u64>

This card’s rank/popularity on Penny Dreadful. Not all cards are ranked.

§defense: Option<String>

This face’s defense, if any.

§artist: Option<String>

The name of the illustrator of this card. Newly spoiled cards may not have this field yet.

§artist_ids: Option<Vec<Uuid>>

The IDs of the artists that illustrated this card. Newly spoiled cards may not have this field yet.

§booster: bool

Whether this card is found in boosters.

§border_color: BorderColor

This card’s border color: black, borderless, gold, silver, or white.

§card_back_id: Option<Uuid>

The Scryfall ID for the card back design present on this card.

§collector_number: String

This card’s collector number. Note that collector numbers can contain non-numeric characters, such as letters or .

§content_warning: bool

True if you should consider avoiding use of this print downstream.

§digital: bool

True if this card was only released in a video game.

§flavor_name: Option<String>

The just-for-fun name printed on the card (such as for Godzilla series cards).

§flavor_text: Option<String>

The flavor text, if any.

§frame_effects: Vec<FrameEffect>

This card’s frame effects, if any.

§frame: Frame

This card’s frame layout.

§full_art: bool

True if this card’s artwork is larger than normal.

§games: Vec<Game>

A list of games that this card print is available in, paper, arena, and/or mtgo.

§highres_image: bool

True if this card’s imagery is high resolution.

§illustration_id: Option<Uuid>

A unique identifier for the card artwork that remains consistent across reprints. Newly spoiled cards may not have this field yet.

§image_status: ImageStatus

A computer-readable indicator for the state of this card’s image, one of missing, placeholder, lowres, or highres_scan.

§image_uris: Option<ImageUris>

An object listing available imagery for this card. See the Card Imagery article for more information.

§prices: Price

An object containing daily price information for this card, including usd, usd_foil, eur, and tix prices, as strings.

§printed_name: Option<String>

The localized name printed on this card, if any.

§printed_text: Option<String>

The localized text printed on this card, if any.

§printed_type_line: Option<String>

The localized type line printed on this card, if any.

§promo: bool

True if this card is a promotional print.

§purchase_uris: Option<PurchaseUris>

An object providing URIs to this card’s listing on major marketplaces.

§rarity: Rarity

This card’s rarity. One of common, uncommon, rare, or mythic.

§related_uris: Option<RelatedUris>

An object providing URIs to this card’s listing on other Magic: The Gathering online resources.

§released_at: NaiveDate

The date this card was first released.

§reprint: bool

True if this card is a reprint.

§scryfall_set_uri: String

A link to this card’s set on Scryfall’s website.

§set_name: String

This card’s full set name.

§set_search_uri: Uri<List<Card>>

A link to where you can begin paginating this card’s set on the Scryfall API.

§set_type: SetType

The type of set this printing is in.

§set_uri: Uri<Set>

A link to this card’s set object on Scryfall’s API.

§set: SetCode

This card’s set code.

§set_id: Uuid

The scryfall id of the set it belongs to.

§story_spotlight: bool

True if this card is a Story Spotlight.

§textless: bool

True if the card is printed without text.

§variation: bool

Whether this card is a variation of another printing.

§variation_of: Option<Uuid>

The printing ID of the printing this card is a variation of.

§watermark: Option<String>

This card’s watermark, if any.

§preview: Preview

Information about when and where the card was originally previewed.

§finishes: Vec<Finishes>

The finishes the card can come in.

§security_stamp: Option<SecurityStamp>

The security stamp on this card, if any.

§promo_types: Vec<PromoType>

An array of strings describing what categories of promo cards this card falls into.

§attraction_lights: Option<Vec<u8>>

The lit Unfinity attractions lights on this card, if any.

Implementations§

Source§

impl Card

Source

pub async fn random() -> Result<Card>

Fetches a random card.

§Examples
let card = Card::random().await?;
println!("{}", &card.name);
Source

pub async fn search(query: impl Search) -> Result<ListIter<Card>>

Returns a ListIter of the cards that match the search terms.

§Examples
use scryfall::card::Card;
use futures::stream::{self, StreamExt};
use futures::future;
assert!(
    Card::search("lightning").await
        .unwrap()
        .into_stream()
        .map(Result::unwrap)
        .all(|x| {
            future::ready(
                x.name.to_lowercase().contains("lightning") ||
                x.flavor_name.is_some_and(|n| n.to_lowercase().contains("lightning"))
            )
        })
        .await
)
use scryfall::card::Card;
use futures::stream::{self, StreamExt};
use futures::future;
assert!(
    Card::search("lightning").await
        .unwrap()
        .into_stream_buffered(10)
        .map(Result::unwrap)
        .all(|x| {
            future::ready(
                x.name.to_lowercase().contains("lightning") ||
                x.flavor_name.is_some_and(|n| n.to_lowercase().contains("lightning"))
            )
        })
        .await
)
use scryfall::Card;
let mut demolish = Card::search(set("war").and(collector_number(123))).await?.into_stream().map(Result::unwrap);
assert!(demolish.all(|card| future::ready(&card.name == "Demolish")).await);
use scryfall::Card;
let mut demolish = Card::search(set("war").and(collector_number(123))).await?.into_stream_buffered(10).map(Result::unwrap);
assert!(demolish.all(|card| future::ready(&card.name == "Demolish")).await);
use scryfall::{Card, Error};
let error = Card::search(power(gte(NumProperty::Power))).await.unwrap_err();
if let Error::ScryfallError(e) = error {
    assert!(e.details.contains("All of your terms were ignored"));
    assert!(e.warnings.len() > 0);
}
})
Source

pub async fn search_all(query: impl Search) -> Result<Vec<Card>>

Returns all cards that match a query, as a Vec. If there is more than one page of cards, this will involve multiple requests to Scryfall to get all the cards.

use scryfall::search::prelude::*;
use scryfall::Card;
let all_six_sixes = Card::search_all(power(6).and(toughness(6))).await?;
assert!(all_six_sixes.iter().any(|c| &c.name == "Colossal Dreadmaw"));
Source

pub async fn search_random(query: impl Search) -> Result<Card>

Fetches a random card matching a search query.

§Examples
let card = Card::search_random("t:Merfolk").await?;
assert!(card.type_line.unwrap().contains("Merfolk"));
Source

pub async fn named(name: &str) -> Result<Card>

Return a card with the exact name.

§Examples
use scryfall::card::Card;
match Card::named("Lightning Bolt").await {
    Ok(card) => assert_eq!(card.name, "Lightning Bolt"),
    Err(e) => panic!("{:?}", e),
}
use scryfall::error::Error;
assert!(Card::named("Name that doesn't exist").await.is_err())
Source

pub async fn named_fuzzy(query: &str) -> Result<Card>

Return a card using the scryfall fuzzy finder.

§Examples
use scryfall::card::Card;
match Card::named_fuzzy("Light Bolt").await {
    Ok(card) => assert_eq!(card.name, "Lightning Bolt"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn set_and_number(set_code: &str, number: usize) -> Result<Card>

Fetch a card by its set and number.

§Examples
use scryfall::card::Card;
match Card::set_and_number("vma", 4).await {
    Ok(card) => assert_eq!(card.name, "Black Lotus"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn multiverse(multiverse_id: usize) -> Result<Card>

Fetch a card by its multiverse id.

§Examples
use scryfall::card::Card;
match Card::multiverse(409574).await {
    Ok(card) => assert_eq!(card.name, "Strip Mine"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn mtgo(mtgo_id: usize) -> Result<Card>

Fetch a card by its mtgo id.

§Examples
use scryfall::card::Card;
match Card::mtgo(54957).await {
    Ok(card) => assert_eq!(card.name, "Ghost Quarter"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn arena(arena_id: usize) -> Result<Card>

Fetch a card by its arena id.

§Examples
use scryfall::card::Card;
match Card::arena(67330).await {
    Ok(card) => assert_eq!(card.name, "Yargle, Glutton of Urborg"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn tcgplayer(tcgplayer_id: usize) -> Result<Card>

Fetch a card by its tcgplayer id.

§Examples
use scryfall::card::Card;
match Card::tcgplayer(67330).await {
    Ok(card) => assert_eq!(card.name, "Fathom Mage"),
    Err(e) => panic!("{:?}", e),
}
Source

pub async fn scryfall_id(scryfall_id: Uuid) -> Result<Card>

Fetch a card by its Uuid.

§Examples
use scryfall::card::Card;
match Card::scryfall_id("0b81b329-4ef5-4b55-9fe7-9ed69477e96b".parse().unwrap()).await {
    Ok(card) => assert_eq!(card.name, "Cowed by Wisdom"),
    Err(e) => panic!("{:?}", e),
}

Trait Implementations§

Source§

impl Clone for Card

Source§

fn clone(&self) -> Card

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Card

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Card

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Card

Source§

fn eq(&self, other: &Card) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Card

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Card

Auto Trait Implementations§

§

impl Freeze for Card

§

impl RefUnwindSafe for Card

§

impl Send for Card

§

impl Sync for Card

§

impl Unpin for Card

§

impl UnwindSafe for Card

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,