Enum scryfall::search::query::Query

source ·
pub enum Query {
    And(Vec<Query>),
    Or(Vec<Query>),
    Not(Box<Query>),
    Param(Param),
    Custom(String),
}
Expand description

A search query, composed of search parameters and boolean operations.

Query is an expression tree, supporting AND, OR, and NOT operations, with the And, Or, and Not variants respectively. Leaf variants are Param and Custom.

§Examples

use scryfall::card::Rarity;
let one_odd_eldrazi = Query::And(vec![
    Query::Or(vec![power(9), toughness(9)]),
    Query::Custom("t:eldrazi".to_string()),
    set("bfz"),             // A `Param` variant.
    rarity(Rarity::Mythic), // A `Param` variant.
    CardIs::OddCmc.into(),
])
.search()
.await?
.next()
.await
.unwrap()?;
assert_eq!(one_odd_eldrazi.name, "Void Winnower");

For information on search parameters, see the param module.

Variants§

§

And(Vec<Query>)

The returned cards must match all of the sub-queries.

§

Or(Vec<Query>)

The returned cards must match at least one of the sub-queries.

§

Not(Box<Query>)

The returned cards must not match the sub-query.

§

Param(Param)

The returned cards must match the specified search Param.

§

Custom(String)

A custom query, in valid Scryfall syntax.

Note: This variant is provided so that users of this crate can use the latest search features on scryfall.com without waiting for the crate to be updated. If you encounter a situation where this must be used, please file an issue.

Implementations§

source§

impl Query

source

pub fn and(self, other: impl Into<Query>) -> Self

Combines self with other using the boolean AND operation.

source

pub fn or(self, other: impl Into<Query>) -> Self

Combines self with other using the boolean OR operation.

Trait Implementations§

source§

impl Clone for Query

source§

fn clone(&self) -> Query

Returns a copy 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 Query

source§

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

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

impl Default for Query

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl Display for Query

source§

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

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

impl From<CardIs> for Query

source§

fn from(card: CardIs) -> Self

Converts to this type from the input type.
source§

impl From<Criterion> for Query

source§

fn from(criterion: Criterion) -> Self

Converts to this type from the input type.
source§

impl From<Param> for Query

source§

fn from(param: Param) -> Self

Converts to this type from the input type.
source§

impl From<PrintingIs> for Query

source§

fn from(printing: PrintingIs) -> Self

Converts to this type from the input type.
source§

impl PartialEq for Query

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Search for Query

source§

fn write_query(&self, url: &mut Url) -> Result<()>

Write this search as the query for the given Url.
source§

fn search<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<ListIter<Card>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Convenience method for passing this object to Card::search.
source§

fn search_all<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Vec<Card>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Convenience method for passing this object to Card::search_all.
source§

fn random<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = Result<Card>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

Convenience method for passing this object to Card::search_random.
source§

impl StructuralPartialEq for Query

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnwindSafe for Query

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> 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> ToOwned for T
where T: Clone,

§

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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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>,

§

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