Struct Client

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub async fn get_card( &self, request: GetCardRequest, ) -> Result<Card, ClientError>

Fetch the details of a single card.

https://docs.pokemontcg.io/api-reference/cards/get-card

Source

pub async fn search_cards( &self, request: SearchCardsRequest, ) -> Result<Vec<Card>, ClientError>

Search for one or many cards given a search query.

https://docs.pokemontcg.io/api-reference/cards/search-cards

Source

pub async fn get_all_cards(&self) -> Result<Vec<Card>, ClientError>

Get all cards (will take awhile, automatically pages through data)

Source§

impl Client

Source

pub fn new(api_key: Option<&str>) -> Result<Self, ClientError>

Constructs a new client

§Errors

This method fails if the API key is invalid (“\n” etc.) or if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Source

pub fn with_base_url( base_url: &str, api_key: Option<&str>, ) -> Result<Self, ClientError>

Constructs a client with a different base url than the default for the API.

§Errors

This method fails if the API key is invalid (“\n” etc.) or if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Source

pub fn with_api_key(api_key: &str) -> Result<Self, ClientError>

Constructs a client with an API key that will be passed on every request.

§Errors

This method fails if the API key is invalid (“\n” etc.) or if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Source§

impl Client

Source

pub async fn get_set(&self, request: GetSetRequest) -> Result<Set, ClientError>

Fetch the details of a single set.

https://docs.pokemontcg.io/api-reference/sets/get-set

Source

pub async fn search_sets( &self, request: SearchSetsRequest, ) -> Result<Vec<Set>, ClientError>

Search for one or many sets given a search query.

https://docs.pokemontcg.io/api-reference/sets/search-cards

Source

pub async fn get_all_sets(&self) -> Result<Vec<Set>, ClientError>

Get all sets (automatically pages through data)

Source§

impl Client

Source

pub async fn get_types(&self) -> Result<Vec<String>, ClientError>

Get all possible types

https://docs.pokemontcg.io/api-reference/types/get-types

Source

pub async fn get_subtypes(&self) -> Result<Vec<String>, ClientError>

Get all possible subtypes

https://docs.pokemontcg.io/api-reference/subtypes/get-subtypes

Source

pub async fn get_supertypes(&self) -> Result<Vec<String>, ClientError>

Get all possible supertypes

https://docs.pokemontcg.io/api-reference/supertypes/get-supertypes

Source

pub async fn get_rarities(&self) -> Result<Vec<String>, ClientError>

Get all possible rarities

https://docs.pokemontcg.io/api-reference/rarities/get-rarities

Trait Implementations§

Source§

impl Default for Client

Source§

fn default() -> Self

Constructs a basic client with no API Key using the default URL.

§Panics

This method will panic if the construction of the reqwest http client fails, if a TLS backend cannot be initialized, or the resolver cannot load the system configuration.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

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, 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T