Struct twitch_api::HelixClient

source ·
pub struct HelixClient<'a, C: 'a> { /* private fields */ }
Available on crate features client and helix only.
Expand description

Client for Helix or the New Twitch API

Use HelixClient::new or HelixClient::with_client to create a new client.

use twitch_api::HelixClient;
let helix: HelixClient<reqwest::Client> = HelixClient::new();

See req_get for GET, req_put for PUT, req_post for POST, req_patch for PATCH and req_delete for DELETE

Most clients will be able to use the 'static lifetime, which typically means it can be elided.

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_api::helix::{users::User, HelixClient};
let client: HelixClient<'static, reqwest::Client> = HelixClient::default();
let user: Option<User> = client
    .get_user_from_login("justintv", &token)
    .await
    .unwrap();

Implementations§

source§

impl<'client, C: HttpClient + Sync + 'client> HelixClient<'client, C>

source

pub async fn get_user_from_login<T>( &'client self, login: impl Into<&UserNameRef> + Send, token: &T ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Sync + Send + ?Sized,

Get User from user login

source

pub async fn get_user_from_id<T>( &'client self, id: impl Into<&UserIdRef> + Send, token: &T ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get User from user id

source

pub async fn get_users_from_ids<T>( &'client self, ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Option<User>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get multiple Users from user ids.

source

pub async fn get_channel_from_login<T>( &'client self, login: impl Into<&UserNameRef> + Send, token: &T ) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get ChannelInformation from a broadcasters login

source

pub async fn get_channel_from_id<T>( &'client self, id: impl Into<&UserIdRef> + Send, token: &T ) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get ChannelInformation from a broadcasters id

source

pub async fn get_channels_from_ids<'b, T>( &'client self, ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Vec<ChannelInformation>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get multiple ChannelInformation from broadcasters ids

Examples
use twitch_api::{helix, types};

let ids: &[&types::UserIdRef] = &["1234".into(), "4321".into()];
let chatters: Vec<helix::channels::ChannelInformation> = client
   .get_channels_from_ids(ids, &token).await?;
source

pub fn get_chatters<T>( &'client self, broadcaster_id: impl Into<&'client UserIdRef>, moderator_id: impl Into<&'client UserIdRef>, batch_size: impl Into<Option<usize>>, token: &'client T ) -> impl Stream<Item = Result<Chatter, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature unsupported only.

Get chatters in a stream Chatter

batch_size sets the amount of chatters to retrieve per api call, max 1000, defaults to 100.

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let chatters: Vec<helix::chat::Chatter> = client
   .get_chatters("1234", "4321", 1000, &token)
   .try_collect().await?;
source

pub fn search_categories<T>( &'client self, query: impl Into<&'client str>, token: &'client T ) -> impl Stream<Item = Result<Category, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Search Categories

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let categories: Vec<helix::search::Category> = client
    .search_categories("Fortnite", &token)
    .try_collect().await?;
source

pub fn search_channels<'b, T>( &'client self, query: impl Into<&'b str>, live_only: bool, token: &'client T ) -> impl Stream<Item = Result<Channel, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized, 'b: 'client,

Search Channels via channel name or description

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let channel: Vec<helix::search::Channel> = client
    .search_channels("twitchdev", false, &token)
    .try_collect().await?;
source

pub fn get_followed_streams<T>( &'client self, token: &'client T ) -> impl Stream<Item = Result<Stream, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get authenticated users’ followed streams

Requires token with scope user:read:follows.

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let channels: Vec<helix::streams::Stream> = client
    .get_followed_streams(&token)
    .try_collect().await?;
source

pub fn get_broadcaster_subscriptions<T>( &'client self, token: &'client T ) -> impl Stream<Item = Result<BroadcasterSubscription, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get authenticated broadcasters’ subscribers

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let subs: Vec<helix::subscriptions::BroadcasterSubscription> = client
    .get_broadcaster_subscriptions(&token)
    .try_collect().await?;
source

pub fn get_moderators_in_channel_from_id<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T ) -> impl Stream<Item = Result<Moderator, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get all moderators in a channel Get Moderators

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let moderators: Vec<helix::moderation::Moderator> = client
    .get_moderators_in_channel_from_id("twitchdev", &token)
    .try_collect().await?;
source

pub fn get_banned_users_in_channel_from_id<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T ) -> impl Stream<Item = Result<BannedUser, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get all banned users in a channel Get Banned Users

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let moderators: Vec<helix::moderation::BannedUser> = client.get_banned_users_in_channel_from_id("twitchdev", &token).try_collect().await?;
source

pub async fn get_total_channel_followers<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<i64, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get a broadcasters follow count

Notes

You need to have the scope moderator:read:followers and be a moderator of the channel if the token is not the broadcasters own token

source

pub fn get_followed_channels<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T ) -> impl Stream<Item = Result<FollowedBroadcaster, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get users followed channels

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let schedule: Vec<helix::channels::FollowedBroadcaster> = client
    .get_followed_channels("1234", &token)
    .try_collect()
    .await?;
source

pub async fn get_games_by_id<T>( &'client self, ids: impl AsRef<[&'client CategoryIdRef]> + Send, token: &T ) -> Result<HashMap<CategoryId, Game>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

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

source

pub async fn block_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<BlockUser, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Block a user

source

pub async fn unblock_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<UnblockUser, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Unblock a user

source

pub async fn ban_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, reason: impl Into<&'b str> + Send, duration: impl Into<Option<u32>> + Send, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<BanUser, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Ban a user

source

pub async fn unban_user<'b, T>( &'client self, target_user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<UnbanUserResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Unban a user

source

pub fn get_channel_schedule<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T ) -> impl Stream<Item = Result<Segment, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get all scheduled streams in a channel.

Notes

Make sure to limit the data here using try_take_while, otherwise this will never end on recurring scheduled streams.

Examples
use twitch_api::helix;
use futures::TryStreamExt;

let schedule: Vec<helix::schedule::Segment> = client
    .get_channel_schedule("twitchdev", &token)
    .try_take_while(|s| {
        futures::future::ready(Ok(!s.start_time.as_str().starts_with("2021-10")))
    })
    .try_collect()
    .await?;
source

pub async fn get_global_emotes<T>( &'client self, token: &T ) -> Result<Vec<GlobalEmote>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get all global emotes

source

pub async fn get_channel_emotes_from_id<'b, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<Vec<ChannelEmote>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get channel emotes in channel with user id

source

pub async fn get_channel_emotes_from_login<T>( &'client self, login: impl IntoCow<'client, UserNameRef> + Send + 'client, token: &T ) -> Result<Option<Vec<ChannelEmote>>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get channel emotes in channel with user login

source

pub async fn get_emote_sets<T>( &'client self, emote_sets: impl AsRef<[&EmoteSetIdRef]> + Send, token: &T ) -> Result<Vec<Emote>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get emotes in emote set

source

pub async fn get_chat_settings<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl Into<Option<&'b UserIdRef>> + Send + 'b, token: &T ) -> Result<ChatSettings, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get a broadcaster’s chat settings

source

pub async fn send_chat_announcement<'b, T, E>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, message: impl Into<&'b str> + Send, color: impl TryInto<AnnouncementColor, Error = E> + Send, token: &T ) -> Result<SendChatAnnouncementResponse, ClientExtError<C, E>>where T: TwitchToken + Send + Sync + ?Sized,

Send a chat announcement

source

pub async fn delete_chat_message<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, message_id: impl IntoCow<'b, MsgIdRef> + Send + 'b, token: &T ) -> Result<DeleteChatMessagesResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Delete a specific chat message

source

pub async fn delete_all_chat_message<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<DeleteChatMessagesResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Delete all chat messages in a broadcasters chat room

source

pub async fn start_a_raid<'b, T>( &'client self, from_broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, to_broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<StartARaidResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Start a raid

source

pub async fn cancel_a_raid<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<CancelARaidResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Cancel a raid

source

pub async fn get_user_chat_color<T>( &'client self, user_id: impl Into<&UserIdRef> + Send, token: &T ) -> Result<Option<UserChatColor>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get a users chat color

source

pub async fn update_user_chat_color<'b, T>( &'client self, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, color: impl Into<NamedUserColor<'b>> + Send + 'b, token: &T ) -> Result<UpdateUserChatColorResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get a users chat color

source

pub async fn get_users_chat_colors<T>( &'client self, user_ids: impl AsRef<[&UserIdRef]> + Send, token: &T ) -> Result<Vec<UserChatColor>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get multiple users chat colors

source

pub async fn add_channel_moderator<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<AddChannelModeratorResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Add a channel moderator

source

pub async fn remove_channel_moderator<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, moderator_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<RemoveChannelModeratorResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Remove a channel moderator

source

pub fn get_vips_in_channel<'b: 'client, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + 'b, token: &'client T ) -> impl Stream<Item = Result<Vip, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Get channel VIPs

source

pub async fn add_channel_vip<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<AddChannelVipResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Add a channel vip

source

pub async fn remove_channel_vip<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, user_id: impl IntoCow<'b, UserIdRef> + Send + 'b, token: &T ) -> Result<RemoveChannelVipResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Remove a channel vip

source

pub async fn send_whisper<'b, T>( &'client self, from: impl IntoCow<'b, UserIdRef> + Send + 'b, to: impl IntoCow<'b, UserIdRef> + Send + 'b, message: impl Into<&'b str> + Send, token: &T ) -> Result<SendWhisperResponse, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Send a whisper

source

pub async fn get_all_custom_rewards<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, only_managable_rewards: bool, token: &T ) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get all custom rewards

Examples
use twitch_api::helix;

let rewards: Vec<helix::points::CustomReward> = client
    .get_all_custom_rewards("1234", true, &token)
    .await?;
source

pub async fn get_custom_rewards<'b, T>( &'client self, broadcaster_id: impl IntoCow<'b, UserIdRef> + Send + 'b, only_managable_rewards: bool, ids: &'b [&'b RewardIdRef], token: &T ) -> Result<Vec<CustomReward>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Get specific custom rewards, see get_all_custom_rewards to get all rewards

Examples
use twitch_api::helix;

let rewards: Vec<helix::points::CustomReward> = client
    .get_custom_rewards("1234", true, &["8969ec47-55b6-4559-a8fe-3f1fc4e6fe58".into()], &token)
    .await?;
source

pub async fn create_eventsub_subscription<T, E: EventSubscription + Send>( &'client self, subscription: E, transport: Transport, token: &T ) -> Result<CreateEventSubSubscription<E>, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Create an EventSub subscription

source

pub async fn delete_eventsub_subscription<'b, T>( &'client self, id: impl IntoCow<'b, EventSubIdRef> + Send + 'b, token: &T ) -> Result<DeleteEventSubSubscription, ClientRequestError<<C as HttpClient>::Error>>where T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Delete an EventSub subscription

source

pub fn get_eventsub_subscriptions<'b: 'client, T>( &'client self, status: impl Into<Option<Status>>, event_type: impl Into<Option<EventType>>, user_id: Option<&'b UserIdRef>, token: &'client T ) -> impl Stream<Item = Result<EventSubSubscriptions, ClientRequestError<<C as HttpClient>::Error>>> + Send + Unpin + 'clientwhere T: TwitchToken + Send + Sync + ?Sized,

Available on crate feature eventsub only.

Get all EventSub subscriptions for this Client

Notes

The return item is a struct EventSubSubscriptions which contains the subscriptions. See the example for getting only the subscriptions

Examples
use twitch_api::{helix, eventsub};
use futures::{TryStreamExt, stream};

let mut total_cost = None;

let chatters: Vec<eventsub::EventSubSubscription> = client
    .get_eventsub_subscriptions(None, None, None, &token)
    .map_ok(|r| {
        total_cost = Some(r.total_cost);
        stream::iter(
            r.subscriptions
                .into_iter()
                .map(Ok::<_, twitch_api::helix::ClientRequestError<_>>),
        )
    })
    .try_flatten()
    .try_collect()
    .await?;
source§

impl<C: HttpClient> HelixClient<'_, C>

source

pub async fn req_get_custom<'d, R, D, T>( &self, request: R, token: &T ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>where R: Request + RequestGet, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send,

Available on crate feature unsupported only.

Request on a valid RequestGet endpoint, with the ability to return borrowed data and specific fields.

source

pub async fn req_post_custom<'d, R, B, D, T>( &self, request: R, body: B, token: &T ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>where R: Request + RequestPost + RequestPost<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send,

Available on crate feature unsupported only.

Request on a valid RequestPost endpoint, with the ability to return borrowed data and specific fields.

source

pub async fn req_patch_custom<'d, R, B, D, T, F>( &self, request: R, body: B, token: &T, function: F ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>where R: Request + RequestPatch + RequestPatch<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestPatchError>,

Available on crate feature unsupported only.

Request on a valid RequestPatch endpoint, with the ability to return borrowed data and specific fields.

Notes

This is probably not useful, as PATCH endpoints do not usually return json

source

pub async fn req_delete_custom<'d, R, D, T, F>( &self, request: R, token: &T, function: F ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>where R: Request + RequestDelete, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,

Available on crate feature unsupported only.

Request on a valid RequestDelete endpoint, with the ability to return borrowed data and specific fields.

Notes

This is probably not useful, as DELETE endpoints do not usually return json

source

pub async fn req_put_custom<'d, R, B, D, T, F>( &self, request: R, body: B, token: &T, function: F ) -> Result<CustomResponse<'d, R, D>, ClientRequestError<<C as HttpClient>::Error>>where R: Request + RequestPut + RequestPut<Body = B>, B: HelixRequestBody, D: Deserialize<'d> + 'd, T: TwitchToken + ?Sized, C: Send, F: Fn(&R, &Uri, &str, StatusCode) -> Result<(), HelixRequestDeleteError>,

Available on crate feature unsupported only.

Request on a valid RequestPut endpoint, with the ability to return borrowed data and specific fields.

Notes

This is probably not useful, as PUT endpoints do not usually return json

source§

impl<'a, C: HttpClient + 'a> HelixClient<'a, C>

source

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

Create a new client with an existing client

source

pub fn new() -> HelixClient<'a, C>where C: ClientDefault<'a>,

Create a new HelixClient with a default HttpClient

source

pub fn clone_client(&self) -> Cwhere C: Clone,

Retrieve a clone of the HttpClient inside this HelixClient

source

pub fn get_client(&self) -> &C

Retrieve a reference of the HttpClient inside this HelixClient

source

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

Request on a valid RequestGet endpoint

let ids: &[&twitch_types::UserIdRef] = &["123456".into()];
let req = channels::GetChannelInformationRequest::broadcaster_ids(ids);
let client = HelixClient::new();

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

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

Request on a valid RequestPost endpoint

source

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

Request on a valid RequestPatch endpoint

source

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

Request on a valid RequestDelete endpoint

source

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

Request on a valid RequestPut endpoint

Trait Implementations§

source§

impl<'c, C: Client + Sync + 'c> Client for HelixClient<'c, C>

§

type Error = CompatError<<C as Client>::Error>

Error returned by the client
source§

fn req( &self, request: Request<Vec<u8>> ) -> BoxedFuture<'_, Result<Response<Vec<u8>>, <Self as Client>::Error>>

Send a request
source§

impl<'a, C> Clone for HelixClient<'a, C>where C: HttpClient + Clone + 'a,

source§

fn clone(&self) -> Self

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<C: HttpClient + ClientDefault<'static>> Default for HelixClient<'static, C>

source§

fn default() -> Self

Creates a new HelixClient with a default HttpClient.

See ClientDefault::default_client_with_name for setting a product name in the User Agent.

Auto Trait Implementations§

§

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

§

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

§

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§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere 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 Twhere 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 Twhere 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<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

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