Struct twitch_api2::helix::HelixClient [−][src]
pub struct HelixClient<'a, C> where
C: HttpClient<'a>, { /* fields omitted */ }
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]
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]
&'a self,
login: impl Into<UserName>,
token: &T
) -> Result<Option<User>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
id: impl Into<UserId>,
token: &T
) -> Result<Option<User>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
login: impl Into<UserName>,
token: &T
) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
id: impl Into<UserId>,
token: &T
) -> Result<Option<ChannelInformation>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
query: impl Into<String>,
token: &T
) -> Result<Vec<Category>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
query: impl Into<String>,
live_only: bool,
token: &T
) -> Result<Vec<Channel>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
token: &T
) -> Result<Vec<Stream>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
broadcaster_id: impl Into<UserId>,
token: &T
) -> Result<Vec<Moderator>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
login: impl Into<UserName>,
token: &T
) -> Result<Option<i64>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
to_id: impl Into<UserId>,
token: &T
) -> Result<i64, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
ids: &[CategoryId],
token: &T
) -> Result<HashMap<CategoryId, Game>, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
target_user_id: impl Into<UserId>,
token: &T
) -> Result<BlockUser, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
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]
&'a self,
target_user_id: impl Into<UserId>,
token: &T
) -> Result<UnblockUser, ClientRequestError<<C as HttpClient<'a>>::Error>> where
T: TwitchToken,
Unblock a user
impl<'a, C: HttpClient<'a>> HelixClient<'a, C>
[src]
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]
C: Default,
Create a new HelixClient
with a default HttpClient
pub fn clone_client(&self) -> C where
C: Clone,
[src]
C: Clone,
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]
&'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,
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]
&'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,
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<D, ClientRequestError<<C as HttpClient<'a>>::Error>> where
R: Request<Response = D> + Request + RequestPatch<Body = B>,
B: HelixRequestBody,
D: TryFrom<StatusCode, Error = Cow<'static, str>> + DeserializeOwned + PartialEq,
T: TwitchToken,
[src]
&'a self,
request: R,
body: B,
token: &T
) -> Result<D, ClientRequestError<<C as HttpClient<'a>>::Error>> where
R: Request<Response = D> + Request + RequestPatch<Body = B>,
B: HelixRequestBody,
D: TryFrom<StatusCode, Error = Cow<'static, str>> + DeserializeOwned + PartialEq,
T: TwitchToken,
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]
&'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,
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]
&'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,
Request on a valid RequestPut
endpoint
Trait Implementations
impl<'a, C: Clone> Clone for HelixClient<'a, C> where
C: HttpClient<'a>,
[src]
impl<'a, C: Clone> Clone for HelixClient<'a, C> where
C: HttpClient<'a>,
[src]fn clone(&self) -> HelixClient<'a, C>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'a, C> Default for HelixClient<'a, C> where
C: HttpClient<'a> + Default,
[src]
impl<'a, C> Default for HelixClient<'a, C> where
C: HttpClient<'a> + Default,
[src]fn default() -> HelixClient<'a, C>
[src]
Auto Trait Implementations
impl<'a, C> RefUnwindSafe for HelixClient<'a, C> where
C: RefUnwindSafe,
impl<'a, C> RefUnwindSafe for HelixClient<'a, C> where
C: RefUnwindSafe,
impl<'a, C> Send for HelixClient<'a, C>
impl<'a, C> Send for HelixClient<'a, C>
impl<'a, C> Sync for HelixClient<'a, C> where
C: Sync,
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> Unpin for HelixClient<'a, C> where
C: Unpin,
impl<'a, C> UnwindSafe for HelixClient<'a, C> where
C: UnwindSafe,
impl<'a, C> UnwindSafe for HelixClient<'a, C> where
C: UnwindSafe,
Blanket Implementations
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
impl<T> WithSubscriber for T
[src]pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,