Skip to content

Commit 788c4ea

Browse files
EmilgardisNerixyz
andcommitted
Apply suggestions from code review
Co-authored-by: nerix <[email protected]>
1 parent 070655c commit 788c4ea

File tree

8 files changed

+35
-26
lines changed

8 files changed

+35
-26
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ exclude = ["twitch_types", "twitch_oauth2"]
2929
[workspace.dependencies]
3030
twitch_api = { version = "0.7.0-rc.6", path = "." }
3131
twitch_oauth2 = { version = "0.13.0", path = "twitch_oauth2/" }
32-
twitch_types = { version = "0.4.3", features = [
32+
twitch_types = { version = "0.4.5", features = [
3333
"serde",
3434
], path = "./twitch_types" }
3535

examples/channel_information_custom.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
2727

2828
let resp = client
2929
.req_get_custom(
30-
helix::channels::GetChannelInformationRequest::broadcaster_ids(vec![&token.user_id]),
30+
helix::channels::GetChannelInformationRequest::broadcaster_ids(&token.user_id),
3131
&token,
3232
)
3333
.await

src/helix/client/client_ext.rs

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
5757
/// use futures::TryStreamExt;
5858
///
5959
/// let users: Vec<helix::users::User> = client
60-
/// .get_users_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
60+
/// .get_users_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
6161
/// # Ok(()) }
6262
/// ```
6363
pub fn get_users_from_ids<T>(
@@ -126,7 +126,7 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
126126
/// use futures::TryStreamExt;
127127
///
128128
/// let chatters: Vec<helix::channels::ChannelInformation> = client
129-
/// .get_channels_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
129+
/// .get_channels_from_ids(&["1234", "4321"][..].into(), &token).try_collect().await?;
130130
/// # Ok(()) }
131131
/// ```
132132
pub fn get_channels_from_ids<T>(
@@ -163,7 +163,10 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
163163
/// use twitch_api::{types, helix};
164164
/// use futures::TryStreamExt;
165165
///
166-
/// let live: Vec<helix::streams::Stream> = client.get_streams_from_ids(&["123456", "987654"][..].into(), &token).try_collect().await?;
166+
/// let live: Vec<helix::streams::Stream> = client
167+
/// .get_streams_from_ids(&["123456", "987654"][..].into(), &token)
168+
/// .try_collect()
169+
/// .await?;
167170
/// # Ok(()) }
168171
/// ```
169172
pub fn get_streams_from_ids<T>(
@@ -198,7 +201,10 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
198201
/// use twitch_api::{types, helix};
199202
/// use futures::TryStreamExt;
200203
///
201-
/// let live: Vec<helix::streams::Stream> = client.get_streams_from_logins(&["twitchdev", "justinfan"][..].into(), &token).try_collect().await?;
204+
/// let live: Vec<helix::streams::Stream> = client
205+
/// .get_streams_from_logins(&["twitchdev", "justinfan"][..].into(), &token)
206+
/// .try_collect()
207+
/// .await?;
202208
/// # Ok(()) }
203209
/// ```
204210
pub fn get_streams_from_logins<T>(
@@ -644,7 +650,8 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
644650
/// use twitch_api::{types, helix};
645651
/// use futures::TryStreamExt;
646652
///
647-
/// let games: Vec<helix::games::Game> = client.get_games_by_id(&["509658", "32982", "27471"][..].into(), &token).try_collect().await?;
653+
/// let games: Vec<helix::games::Game> = client
654+
/// .get_games_by_id(&["509658", "32982", "27471"][..].into(), &token).try_collect().await?;
648655
/// # Ok(()) }
649656
/// ```
650657
pub fn get_games_by_id<T>(
@@ -851,7 +858,8 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
851858
/// use twitch_api::{types, helix};
852859
/// use futures::TryStreamExt;
853860
///
854-
/// let games: Vec<helix::chat::get_emote_sets::Emote> = client.get_emote_sets(&["0"][..].into(), &token).try_collect().await?;
861+
/// let emotes: Vec<helix::chat::get_emote_sets::Emote> = client
862+
/// .get_emote_sets(&["0"][..].into(), &token).try_collect().await?;
855863
/// # Ok(()) }
856864
/// ```
857865
pub fn get_emote_sets<T>(
@@ -970,7 +978,7 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
970978
Ok(self.req_delete(req, token).await?.data)
971979
}
972980

973-
/// Get a users chat color
981+
/// Update a user's chat color
974982
pub async fn update_user_chat_color<'b, T>(
975983
&'client self,
976984
user_id: impl types::IntoCow<'b, types::UserIdRef> + Send + 'b,
@@ -988,7 +996,9 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
988996
Ok(self.req_put(req, helix::EmptyBody, token).await?.data)
989997
}
990998

991-
/// Get a users chat color
999+
/// Get a user's chat color
1000+
///
1001+
/// [`None`](Option::None) is returned if the user never set their color in the settings.
9921002
pub async fn get_user_chat_color<T>(
9931003
&'client self,
9941004
user_id: impl Into<&types::UserIdRef> + Send,
@@ -999,14 +1009,16 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
9991009
{
10001010
Ok(self
10011011
.req_get(
1002-
helix::chat::GetUserChatColorRequest::user_ids(&[user_id.into()][..]),
1012+
helix::chat::GetUserChatColorRequest::user_ids(&user_id.into()),
10031013
token,
10041014
)
10051015
.await?
10061016
.first())
10071017
}
10081018

1009-
/// Get multiple users chat colors
1019+
/// Get multiple users' chat colors
1020+
///
1021+
/// Users that never set their color in the settings are not returned.
10101022
///
10111023
/// # Examples
10121024
///
@@ -1019,7 +1031,8 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
10191031
/// use twitch_api::{types, helix};
10201032
/// use futures::TryStreamExt;
10211033
///
1022-
/// let games: Vec<helix::chat::UserChatColor> = client.get_users_chat_colors(&["1234"][..].into(), &token).try_collect().await?;
1034+
/// let colors: Vec<helix::chat::UserChatColor> = client
1035+
/// .get_users_chat_colors(&["1234"][..].into(), &token).try_collect().await?;
10231036
/// # Ok(()) }
10241037
/// ```
10251038
pub fn get_users_chat_colors<T>(
@@ -1217,9 +1230,6 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
12171230
where
12181231
T: TwitchToken + Send + Sync + ?Sized,
12191232
{
1220-
if ids.len() > 50 {
1221-
return Err(ClientRequestError::Custom("too many IDs, max 50".into()));
1222-
}
12231233
Ok(self
12241234
.req_get(
12251235
helix::points::GetCustomRewardRequest::broadcaster_id(broadcaster_id)
@@ -1276,8 +1286,9 @@ impl<'client, C: crate::HttpClient + Sync + 'client> HelixClient<'client, C> {
12761286
///
12771287
/// # Notes
12781288
///
1279-
/// The return item is a struct [`EventSubSubscriptions`](helix::eventsub::EventSubSubscriptions) which contains the subscriptions.
1280-
/// See the example for getting only the subscriptions
1289+
/// The return item is a struct [`EventSubSubscriptions`](helix::eventsub::EventSubSubscriptions)
1290+
/// which contains a field with all the subscriptions.
1291+
/// See the example for collecting all _specific_ subscriptions
12811292
///
12821293
/// # Examples
12831294
///

src/helix/endpoints/chat/get_emote_sets.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! ```rust
1111
//! use twitch_api::helix::chat::get_emote_sets;
12-
//! let request = get_emote_sets::GetEmoteSetsRequest::emote_set_ids(&["1234"]);
12+
//! let request = get_emote_sets::GetEmoteSetsRequest::emote_set_ids(&"1234");
1313
//! ```
1414
//!
1515
//! ## Response: [Emote]
@@ -24,7 +24,7 @@
2424
//! # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
2525
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
2626
//! # let token = twitch_oauth2::UserToken::from_existing(&client, token, None, None).await?;
27-
//! let request = get_emote_sets::GetEmoteSetsRequest::emote_set_ids(&["1234"]);
27+
//! let request = get_emote_sets::GetEmoteSetsRequest::emote_set_ids(&"1234");
2828
//! let response: Vec<helix::chat::get_emote_sets::Emote> = client.req_get(request, &token).await?.data;
2929
//! # Ok(())
3030
//! # }

src/helix/endpoints/streams/get_streams.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
//!
1414
//! To use this endpoint, construct a [`GetStreamsRequest`] with the [`GetStreamsRequest::user_ids()`], [`GetStreamsRequest::user_logins()`] or [`GetStreamsRequest::game_ids()`] method.
1515
//!
16-
//! See also
17-
//!
1816
//! ```rust
1917
//! use twitch_api::helix::streams::get_streams;
2018
//! let request = get_streams::GetStreamsRequest::user_logins(&["justintvfan"]);

src/helix/endpoints/videos/delete_videos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//!
1010
//! ```rust
1111
//! use twitch_api::helix::videos::delete_videos;
12-
//! let request = delete_videos::DeleteVideosRequest::ids(&["1234"]);
12+
//! let request = delete_videos::DeleteVideosRequest::ids(&"1234");
1313
//! ```
1414
//!
1515
//! ## Response: [DeleteVideo]
@@ -24,7 +24,7 @@
2424
//! # let client: helix::HelixClient<'static, client::DummyHttpClient> = helix::HelixClient::default();
2525
//! # let token = twitch_oauth2::AccessToken::new("validtoken".to_string());
2626
//! # let token = twitch_oauth2::UserToken::from_existing(&client, token, None, None).await?;
27-
//! let request = delete_videos::DeleteVideosRequest::ids(&["1234"]);
27+
//! let request = delete_videos::DeleteVideosRequest::ids(&"1234");
2828
//! let response: delete_videos::DeleteVideo = client.req_delete(request, &token).await?.data;
2929
//! # Ok(())
3030
//! # }

0 commit comments

Comments
 (0)