Struct coc_rs::api::Client

source ·
pub struct Client { /* private fields */ }

Implementations§

source§

impl Client

source

pub async fn new(credentials: Credentials) -> Result<Self>

Returns a Client

§Errors

This function will return an error if the credentials are invalid

source

pub async fn load(&self, credentials: Credentials) -> Result<()>

Here you can create a client yourself and load them here later (for example .env parsing)

§Errors

This function will return an error if the credentials are invalid

§Example
use coc_rs::{api::Client, credentials::Credentials};

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let client = Client::new(None);
    let credentials = Credentials::builder()
        .add_credential("email", "password")
        .add_credential("email2", "password2")
        .build();
    client.load(credentials).await?;

    Ok(())
}
source

pub async fn get_clan_warlog( &self, clan_tag: &str ) -> Result<APIResponse<WarLog>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_clans( &self, options: ClanSearchOptions ) -> Result<APIResponse<Clan>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_current_war(&self, clan_tag: &str) -> Result<War, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_clan(&self, clan_tag: &str) -> Result<Clan, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_clan_members( &self, clan_tag: &str ) -> Result<APIResponse<ClanMember>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_clan_capital_raid_seasons( &self, clan_tag: &str ) -> Result<APIResponse<ClanCapitalRaidSeason>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_player(&self, player_tag: &str) -> Result<Player, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn verify_player_token( &self, player_tag: &str, token: &str ) -> Result<PlayerToken, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_leagues(&self) -> Result<APIResponse<League>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_league_season_rankings( &self, league_id: LeagueKind, season_id: Season, paging: Paging ) -> Result<APIResponse<PlayerRanking>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_league( &self, league_id: LeagueKind ) -> Result<League, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_league_seasons( &self, league_id: LeagueKind ) -> Result<APIResponse<Season>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_war_league( &self, war_league: WarLeagueKind ) -> Result<WarLeague, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_war_leagues(&self) -> Result<APIResponse<WarLeague>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_clan_rankings( &self, location: Local ) -> Result<APIResponse<ClanRanking>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_player_rankings( &self, location: Local ) -> Result<APIResponse<PlayerRanking>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_versus_clan_rankings( &self, location: Local ) -> Result<APIResponse<ClanRanking>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_versus_player_rankings( &self, location: Local ) -> Result<APIResponse<PlayerVersusRanking>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_locations(&self) -> Result<APIResponse<Location>, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_location(&self, location: Local) -> Result<Location, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_goldpass(&self) -> Result<GoldPass, APIError>

§Errors

This function will return an error if the request fails

source

pub async fn get_player_labels( &self ) -> Result<APIResponse<PlayerLabel>, APIError>

§Errors

This function will return an error if the request fails.

source

pub async fn get_clan_labels(&self) -> Result<APIResponse<ClanLabel>, APIError>

§Errors

This function will return an error if the request fails.

Trait Implementations§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

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 Client

source§

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

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

impl Default for Client

source§

fn default() -> Client

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

Auto Trait Implementations§

§

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.

§

impl<T> Instrument for T

§

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

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

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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