Struct twitch_api2::helix::HelixClient[][src]

pub struct HelixClient<'a, C> where
    C: HttpClient<'a>, 
{ /* fields omitted */ }
This is supported on crate features client and helix only.

Client for Helix or the New Twitch API

Provides HelixClient::req_get for requesting endpoints which uses GET method.

Most clients will be able to use the 'static lifetime

pub struct MyStruct {
    twitch: HelixClient<'static, reqwest::Client>,
    token: twitch_oauth2::AppAccessToken,
}
// etc

See HttpClient for implemented http clients, you can also define your own if needed.

Examples

Get a user from their login name.

use twitch_api2::helix::{HelixClient, users::User};
let helix: HelixClient<'static, reqwest::Client> = HelixClient::default();
let user: Option<User> = helix
    .get_user_from_login("justintv".to_string(), &token).await.unwrap();

Implementations

impl<'a, C: HttpClient<'a>> HelixClient<'a, C>[src]

pub async fn get_user_from_login<T: ?Sized>(
    &'a self,
    login: impl Into<UserName>,
    token: &T
) -> Result<Option<User>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get User from user login

pub async fn get_user_from_id<T: ?Sized>(
    &'a self,
    id: impl Into<UserId>,
    token: &T
) -> Result<Option<User>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get User from user id

pub async fn get_channel_from_login<T: ?Sized>(
    &'a self,
    login: impl Into<UserName>,
    token: &T
) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get ChannelInformation from a broadcasters login

pub async fn get_channel_from_id<T: ?Sized>(
    &'a self,
    id: impl Into<UserId>,
    token: &T
) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get ChannelInformation from a broadcasters id

pub async fn search_categories<T: ?Sized>(
    &'a self,
    query: impl Into<String>,
    token: &T
) -> Result<Vec<Category>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Search Categories

pub async fn search_channels<T: ?Sized>(
    &'a self,
    query: impl Into<String>,
    live_only: bool,
    token: &T
) -> Result<Vec<Channel>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Search Channels

pub async fn get_followed_streams<T: ?Sized>(
    &'a self,
    token: &T
) -> Result<Vec<Stream>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get authenticated users followed streams

pub async fn get_moderators_in_channel_from_id<T: ?Sized>(
    &'a self,
    broadcaster_id: impl Into<UserId>,
    token: &T
) -> Result<Vec<Moderator>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get all moderators in a channel Channels

pub async fn get_total_followers_from_login<T: ?Sized>(
    &'a self,
    login: impl Into<UserName>,
    token: &T
) -> Result<Option<i64>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get a users, with login, follow count

pub async fn get_total_followers_from_id<T: ?Sized>(
    &'a self,
    to_id: impl Into<UserId>,
    token: &T
) -> Result<i64, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get a users, with id, follow count

Notes

This returns zero if the user doesn’t exist

pub async fn get_games_by_id<T: ?Sized>(
    &'a self,
    ids: &[CategoryId],
    token: &T
) -> Result<HashMap<CategoryId, Game>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Get games by ID. Can only be at max 100 ids.

pub async fn block_user<T: ?Sized>(
    &'a self,
    target_user_id: impl Into<UserId>,
    token: &T
) -> Result<BlockUser, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Block a user

pub async fn unblock_user<T: ?Sized>(
    &'a self,
    target_user_id: impl Into<UserId>,
    token: &T
) -> Result<UnblockUser, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    T: TwitchToken
[src]

Unblock a user

impl<'a, C: HttpClient<'a>> HelixClient<'a, C>[src]

pub fn with_client(client: C) -> HelixClient<'a, C>[src]

Create a new client with an existing client

pub fn new() -> HelixClient<'a, C> where
    C: Default
[src]

Create a new HelixClient with a default HttpClient

pub fn clone_client(&self) -> C where
    C: Clone
[src]

Retrieve a clone of the HttpClient inside this HelixClient

pub async fn req_get<R, D, T: ?Sized>(
    &'a self,
    request: R,
    token: &T
) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    R: Request<Response = D> + Request + RequestGet,
    D: DeserializeOwned + PartialEq,
    T: TwitchToken
[src]

Request on a valid RequestGet endpoint

    let req = channels::GetChannelInformationRequest::builder().broadcaster_id("123456").build();
    let client = HelixClient::new();

    let response = client.req_get(req, &token).await;

pub async fn req_post<R, B, D, T: ?Sized>(
    &'a self,
    request: R,
    body: B,
    token: &T
) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    R: Request<Response = D> + Request + RequestPost<Body = B>,
    B: HelixRequestBody,
    D: DeserializeOwned + PartialEq,
    T: TwitchToken
[src]

Request on a valid RequestPost endpoint

pub async fn req_patch<R, B, D, T: ?Sized>(
    &'a self,
    request: R,
    body: B,
    token: &T
) -> Result<Response<R, D>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    R: Request<Response = D> + Request + RequestPatch<Body = B>,
    B: HelixRequestBody,
    D: DeserializeOwned + PartialEq,
    T: TwitchToken
[src]

Request on a valid RequestPatch endpoint

pub async fn req_delete<R, D, T: ?Sized>(
    &'a self,
    request: R,
    token: &T
) -> Result<D, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    R: Request<Response = D> + Request + RequestDelete,
    D: TryFrom<StatusCode, Error = Cow<'static, str>> + DeserializeOwned + PartialEq,
    T: TwitchToken
[src]

Request on a valid RequestDelete endpoint

pub async fn req_put<R, B, D, T: ?Sized>(
    &'a self,
    request: R,
    body: B,
    token: &T
) -> Result<D, ClientRequestError<<C as HttpClient<'a>>::Error>> where
    R: Request<Response = D> + Request + RequestPut<Body = B>,
    B: HelixRequestBody,
    D: TryFrom<StatusCode, Error = Cow<'static, str>> + DeserializeOwned + PartialEq,
    T: TwitchToken
[src]

Request on a valid RequestPut endpoint

Trait Implementations

impl<'a, C: Clone> Clone for HelixClient<'a, C> where
    C: HttpClient<'a>, 
[src]

fn clone(&self) -> HelixClient<'a, C>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, C> Default for HelixClient<'a, C> where
    C: HttpClient<'a> + Default
[src]

fn default() -> HelixClient<'a, C>[src]

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

Auto Trait Implementations

impl<'a, C> RefUnwindSafe for HelixClient<'a, C> where
    C: RefUnwindSafe

impl<'a, C> Send for HelixClient<'a, C>

impl<'a, C> Sync for HelixClient<'a, C> where
    C: Sync

impl<'a, C> Unpin for HelixClient<'a, C> where
    C: Unpin

impl<'a, C> UnwindSafe for HelixClient<'a, C> where
    C: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T> Instrument for T[src]

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

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V

impl<T> WithSubscriber for T[src]

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>[src]

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