Client

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