-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Use (mostly) References in Requests #280
Conversation
6c015ca
to
0987e5d
Compare
This is great! i was just starting to implement this myself. Some ideas: I'd like it if we included a trait /// A type which can be converted into an request
pub trait IntoRequest {
/// The request this type turns into
type Request: Request;
/// Into request
fn into_request(self) -> Self::Request;
}
impl<R> IntoRequest for R
where R: Request
{
type Request = Self;
fn into_request(self) -> Self::Request { self }
} and having the pub async fn req_get<R, D, T>(
&'a self,
request: R,
token: &T,
) -> Result<Response<R::Request, D>, ClientRequestError<<C as crate::HttpClient<'a>>::Error>>
where
R: IntoRequest,
R::Request: Request<Response = D> + Request + RequestGet,
D: serde::de::DeserializeOwned + PartialEq,
T: TwitchToken + ?Sized,
C: Send,
{
let request = request.into_request();
todo!()
} I'd also like it if we could keep the ability to use IntoIterator, sadly that wouldn't be possible unless we keep two variants of each struct, one which is mixed/fully owned, and one that is fully borrowed. The |
ping #114 |
this comment is probably better suited for the future, I think the way to do it is via a custom derive with attributes |
examples/channel_information.rs
Outdated
.get_user_from_login(args.next().unwrap(), &token) | ||
.get_user_from_login(&*args.next().unwrap(), &token) | ||
.await? | ||
.expect("no user found"); | ||
|
||
let channel = client | ||
.get_channel_from_id(user.id.clone(), &token) | ||
.get_channel_from_id(&*user.id, &token) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to not have to deref this, we could add
impl<'a> From<&'a UserId> for &'a UserIdRef {
fn from(id: &'a UserId) -> Self {
&*id
}
}
to twitch_types, maybe it should be considered in aliri_braid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Would you be against using Cow
in every place possible? I think I'd prefer using them since you could then have owned data, and we could also then add in a crate like zerofrom
for convenience
I'm not against it. Though the braid types should have convenience impls: |
Unfortunately those are not possible, as the orphan rule forbids them |
Oh yea I forgot you can't implement this. I wanted these impls, because having functions take |
yeah that'd be nice not even this works pub fn broadcaster_id<T: 'a + ToOwned<Owned = types::UserId>>(
broadcaster_id: impl Into<Cow<'a, T>>,
) -> Self
where &'a T: Into<&'a types::UserIdRef> {
Self {
broadcaster_id: match broadcaster_id.into() {
Cow::Borrowed(b) => Cow::Borrowed(b.into()),
Cow::Owned(owned) => Cow::Owned(owned),
},
}
} |
apply this diff and we should be good diff --git a/Cargo.lock b/Cargo.lock
index 4935ae090..fe28d6e46 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2671,7 +2671,7 @@ dependencies = [
[[package]]
name = "twitch_types"
-version = "0.3.5"
+version = "0.3.6"
dependencies = [
"aliri_braid",
"displaydoc",
diff --git a/Cargo.toml b/Cargo.toml
index c715d42a6..5dd58b76c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -57,7 +57,7 @@ crypto_hmac = { package = "hmac", version = "0.12.1", optional = true }
aliri_braid = "0.2.4"
futures = { version = "0.3.25", optional = true }
hyper = { version = "0.14.20", optional = true }
-twitch_types = { version = "0.3.5", path = "./twitch_types" }
+twitch_types = { version = "0.3.6", path = "./twitch_types" }
[features]
default = []
diff --git a/examples/channel_information.rs b/examples/channel_information.rs
index 539151aeb..c1637dd50 100644
--- a/examples/channel_information.rs
+++ b/examples/channel_information.rs
@@ -31,7 +31,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.expect("no user found");
let channel = client
- .get_channel_from_id(&*user.id, &token)
+ .get_channel_from_id(&user.id, &token)
.await?
.expect("no channel found");
diff --git a/examples/channel_information_custom.rs b/examples/channel_information_custom.rs
index 2a7a4d515..3b6a9c6da 100644
--- a/examples/channel_information_custom.rs
+++ b/examples/channel_information_custom.rs
@@ -27,7 +27,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
let resp = client
.req_get_custom(
- helix::channels::GetChannelInformationRequest::broadcaster_id(&*token.user_id),
+ helix::channels::GetChannelInformationRequest::broadcaster_id(&token.user_id),
&token,
)
.await
diff --git a/examples/eventsub/src/main.rs b/examples/eventsub/src/main.rs
index 913e61fbc..4b8a3ff86 100644
--- a/examples/eventsub/src/main.rs
+++ b/examples/eventsub/src/main.rs
@@ -74,7 +74,7 @@ pub async fn run(opts: &Opts) -> eyre::Result<()> {
.await?;
let broadcaster = client
- .get_user_from_login(&*opts.broadcaster_login, &token)
+ .get_user_from_login(&opts.broadcaster_login, &token)
.await?
.ok_or_else(|| eyre::eyre!("broadcaster not found"))?;
diff --git a/examples/mock_api.rs b/examples/mock_api.rs
index f93d6c466..9e5500501 100644
--- a/examples/mock_api.rs
+++ b/examples/mock_api.rs
@@ -59,16 +59,16 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.await?;
let user = client
- .get_user_from_id(&*user_id, &token)
+ .get_user_from_id(&user_id, &token)
.await?
.expect("no user found");
let _channel = client
- .get_channel_from_id(&*user_id, &token)
+ .get_channel_from_id(&user_id, &token)
.await?
.expect("no channel found");
let _channel = client
- .get_channel_from_id(&*user.id, &token)
+ .get_channel_from_id(&user.id, &token)
.await?
.expect("no channel found");
@@ -86,7 +86,7 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
.await?;
dbg!(search.get(0));
let _total = client
- .get_total_followers_from_id(&*search.get(0).unwrap().id, &token)
+ .get_total_followers_from_id(&search.get(0).unwrap().id, &token)
.await?;
dbg!(_total);
let streams: Vec<_> = client.get_followed_streams(&token).try_collect().await?;
diff --git a/examples/modify_channel.rs b/examples/modify_channel.rs
index 5888c8054..09bb4a0f7 100644
--- a/examples/modify_channel.rs
+++ b/examples/modify_channel.rs
@@ -33,19 +33,14 @@ async fn run() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>>
let broadcaster_id = token.validate_token(&client).await?.user_id.unwrap();
let req = twitch_api::helix::channels::ModifyChannelInformationRequest::broadcaster_id(
- &*broadcaster_id,
+ &broadcaster_id,
);
+ let mut body = twitch_api::helix::channels::ModifyChannelInformationBody::new();
+ body.title("Hello World!");
+
println!("scopes: {:?}", token.scopes());
- let response = client
- .req_patch(
- req,
- twitch_api::helix::channels::ModifyChannelInformationBody::builder()
- .title("Hello World!")
- .build(),
- &token,
- )
- .await?;
+ let response = client.req_patch(req, body, &token).await?;
println!("{:?}", response);
Ok(())
diff --git a/src/helix/client/client_ext.rs b/src/helix/client/client_ext.rs
index 1d9186b45..00e475c44 100644
--- a/src/helix/client/client_ext.rs
+++ b/src/helix/client/client_ext.rs
@@ -1,5 +1,7 @@
//! Convenience functions for [HelixClient]
+use std::borrow::Cow;
+
use crate::helix::{self, ClientRequestError, HelixClient};
use crate::types;
use twitch_oauth2::TwitchToken;
@@ -50,16 +52,16 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
T: TwitchToken + ?Sized,
{
if let Some(user) = self.get_user_from_login(login.into(), token).await? {
- self.get_channel_from_id(&*user.id, token).await
+ self.get_channel_from_id(&user.id, token).await
} else {
Ok(None)
}
}
/// Get [ChannelInformation](helix::channels::ChannelInformation) from a broadcasters id
- pub async fn get_channel_from_id<T>(
+ pub async fn get_channel_from_id<'b, T>(
&'a self,
- id: impl Into<&types::UserIdRef>,
+ id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<Option<helix::channels::ChannelInformation>, ClientError<'a, C>>
where
@@ -106,7 +108,7 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
{
let req = helix::chat::GetChattersRequest {
first: batch_size.into(),
- ..helix::chat::GetChattersRequest::new(broadcaster_id, moderator_id)
+ ..helix::chat::GetChattersRequest::new(broadcaster_id.into(), moderator_id.into())
};
make_stream(req, token, self, std::collections::VecDeque::from)
@@ -211,8 +213,8 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
T: TwitchToken + Send + Sync + ?Sized,
{
let mut req = helix::users::GetUsersFollowsRequest::empty();
- req.to_id = to_id.into();
- req.from_id = from_id.into();
+ req.to_id = to_id.into().map(Cow::Borrowed);
+ req.from_id = from_id.into().map(Cow::Borrowed);
make_stream(req, token, self, |s| {
std::collections::VecDeque::from(s.follow_relationships)
@@ -323,9 +325,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
///
/// # Ok(()) }
/// ```
- pub fn get_moderators_in_channel_from_id<T>(
+ pub fn get_moderators_in_channel_from_id<'b: 'a, T>(
&'a self,
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &'a T,
) -> std::pin::Pin<
Box<
@@ -358,9 +360,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
///
/// # Ok(()) }
/// ```
- pub fn get_banned_users_in_channel_from_id<T>(
+ pub fn get_banned_users_in_channel_from_id<'b: 'a, T>(
&'a self,
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &'a T,
) -> std::pin::Pin<
Box<
@@ -377,16 +379,16 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Get a users, with login, follow count
- pub async fn get_total_followers_from_login<T>(
+ pub async fn get_total_followers_from_login<'b, T>(
&'a self,
- login: impl Into<&types::UserNameRef>,
+ login: impl types::IntoCow<'b, types::UserNameRef> + 'b,
token: &T,
) -> Result<Option<i64>, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
- if let Some(user) = self.get_user_from_login(login, token).await? {
- self.get_total_followers_from_id(&*user.id, token)
+ if let Some(user) = self.get_user_from_login(&*login.to_cow(), token).await? {
+ self.get_total_followers_from_id(&user.id, token)
.await
.map(Some)
} else {
@@ -399,9 +401,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
/// # Notes
///
/// This returns zero if the user doesn't exist
- pub async fn get_total_followers_from_id<T>(
+ pub async fn get_total_followers_from_id<'b, T>(
&'a self,
- to_id: impl Into<&types::UserIdRef>,
+ to_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<i64, ClientError<'a, C>>
where
@@ -443,9 +445,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Block a user
- pub async fn block_user<T>(
+ pub async fn block_user<'b, T>(
&'a self,
- target_user_id: impl Into<&types::UserIdRef>,
+ target_user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::users::BlockUser, ClientError<'a, C>>
where
@@ -462,9 +464,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Unblock a user
- pub async fn unblock_user<T>(
+ pub async fn unblock_user<'b, T>(
&'a self,
- target_user_id: impl Into<&types::UserIdRef>,
+ target_user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::users::UnblockUser, ClientError<'a, C>>
where
@@ -480,13 +482,13 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Ban a user
- pub async fn ban_user<T>(
+ pub async fn ban_user<'b, T>(
&'a self,
- target_user_id: impl Into<&types::UserIdRef>,
- reason: impl AsRef<str>,
+ target_user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ reason: impl Into<&'b str>,
duration: impl Into<Option<u32>>,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::BanUser, ClientError<'a, C>>
where
@@ -494,12 +496,8 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
{
Ok(self
.req_post(
- helix::moderation::BanUserRequest::new(broadcaster_id.into(), moderator_id.into()),
- helix::moderation::BanUserBody::new(
- target_user_id.into(),
- reason.as_ref(),
- duration,
- ),
+ helix::moderation::BanUserRequest::new(broadcaster_id, moderator_id),
+ helix::moderation::BanUserBody::new(target_user_id, reason.into(), duration),
token,
)
.await?
@@ -507,11 +505,11 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Unban a user
- pub async fn unban_user<T>(
+ pub async fn unban_user<'b, T>(
&'a self,
- target_user_id: impl Into<&types::UserIdRef>,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
+ target_user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::UnbanUserResponse, ClientError<'a, C>>
where
@@ -520,9 +518,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
Ok(self
.req_delete(
helix::moderation::UnbanUserRequest::new(
- broadcaster_id.into(),
- moderator_id.into(),
- target_user_id.into(),
+ broadcaster_id,
+ moderator_id,
+ target_user_id,
),
token,
)
@@ -559,9 +557,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
///
/// # Ok(()) }
/// ```
- pub fn get_channel_schedule<T>(
+ pub fn get_channel_schedule<'b: 'a, T>(
&'a self,
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &'a T,
) -> std::pin::Pin<
Box<dyn futures::Stream<Item = Result<helix::schedule::Segment, ClientError<'a, C>>> + 'a>,
@@ -587,9 +585,9 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Get channel emotes in channel with user id
- pub async fn get_channel_emotes_from_id<T>(
+ pub async fn get_channel_emotes_from_id<'b, T>(
&'a self,
- user_id: impl Into<&types::UserIdRef>,
+ user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<Vec<helix::chat::ChannelEmote>, ClientError<'a, C>>
where
@@ -602,14 +600,17 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
/// Get channel emotes in channel with user login
pub async fn get_channel_emotes_from_login<T>(
&'a self,
- login: impl Into<&types::UserNameRef>,
+ login: impl types::IntoCow<'a, types::UserNameRef> + 'a,
token: &T,
) -> Result<Option<Vec<helix::chat::ChannelEmote>>, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
- if let Some(user) = self.get_user_from_login(login.into(), token).await? {
- self.get_channel_emotes_from_id(&*user.id, token)
+ if let Some(user) = self
+ .get_user_from_login(login.to_cow().as_ref(), token)
+ .await?
+ {
+ self.get_channel_emotes_from_id(&user.id, token)
.await
.map(Some)
} else {
@@ -631,10 +632,10 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Get a broadcaster's chat settings
- pub async fn get_chat_settings<T>(
+ pub async fn get_chat_settings<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<Option<&'a types::UserIdRef>>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl Into<Option<&'b types::UserIdRef>> + 'b,
token: &T,
) -> Result<helix::chat::ChatSettings, ClientError<'a, C>>
where
@@ -648,22 +649,19 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Send a chat announcement
- pub async fn send_chat_announcement<T, E>(
+ pub async fn send_chat_announcement<'b, T, E>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
- message: impl AsRef<str>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ message: impl Into<&'b str>,
color: impl std::convert::TryInto<helix::chat::AnnouncementColor, Error = E>,
token: &T,
) -> Result<helix::chat::SendChatAnnouncementResponse, ClientExtError<'a, C, E>>
where
T: TwitchToken + ?Sized,
{
- let req = helix::chat::SendChatAnnouncementRequest::new(
- broadcaster_id.into(),
- moderator_id.into(),
- );
- let body = helix::chat::SendChatAnnouncementBody::new(message.as_ref(), color)?;
+ let req = helix::chat::SendChatAnnouncementRequest::new(broadcaster_id, moderator_id);
+ let body = helix::chat::SendChatAnnouncementBody::new(message.into(), color)?;
Ok(self
.req_post(req, body, token)
.await
@@ -672,62 +670,53 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Delete a specific chat message
- pub async fn delete_chat_message<T>(
+ pub async fn delete_chat_message<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
- message_id: impl Into<&types::MsgIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ message_id: impl types::IntoCow<'b, types::MsgIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::DeleteChatMessagesResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
- let req = helix::moderation::DeleteChatMessagesRequest::new(
- broadcaster_id.into(),
- moderator_id.into(),
- )
- .message_id(message_id.into());
+ let req = helix::moderation::DeleteChatMessagesRequest::new(broadcaster_id, moderator_id)
+ .message_id(message_id);
Ok(self.req_delete(req, token).await?.data)
}
/// Delete all chat messages in a broadcasters chat room
- pub async fn delete_all_chat_message<T>(
+ pub async fn delete_all_chat_message<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::DeleteChatMessagesResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
- let req = helix::moderation::DeleteChatMessagesRequest::new(
- broadcaster_id.into(),
- moderator_id.into(),
- );
+ let req = helix::moderation::DeleteChatMessagesRequest::new(broadcaster_id, moderator_id);
Ok(self.req_delete(req, token).await?.data)
}
/// Start a raid
- pub async fn start_a_raid<T>(
+ pub async fn start_a_raid<'b, T>(
&'a self,
- from_broadcaster_id: impl Into<&types::UserIdRef>,
- to_broadcaster_id: impl Into<&types::UserIdRef>,
+ from_broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ to_broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::raids::StartARaidResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
- let req = helix::raids::StartARaidRequest::new(
- from_broadcaster_id.into(),
- to_broadcaster_id.into(),
- );
+ let req = helix::raids::StartARaidRequest::new(from_broadcaster_id, to_broadcaster_id);
Ok(self.req_post(req, helix::EmptyBody, token).await?.data)
}
/// Cancel a raid
- pub async fn cancel_a_raid<T>(
+ pub async fn cancel_a_raid<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::raids::CancelARaidResponse, ClientError<'a, C>>
where
@@ -756,17 +745,17 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Get a users chat color
- pub async fn update_user_chat_color<T>(
+ pub async fn update_user_chat_color<'b, T>(
&'a self,
- user_id: impl Into<&types::UserIdRef>,
- color: impl Into<types::NamedUserColor<'static>>,
+ user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ color: impl Into<types::NamedUserColor<'b>> + 'b,
token: &T,
) -> Result<helix::chat::UpdateUserChatColorResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
let req = helix::chat::UpdateUserChatColorRequest {
- user_id: user_id.into(),
+ user_id: user_id.to_cow(),
color: color.into(),
};
@@ -788,45 +777,45 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Add a channel moderator
- pub async fn add_channel_moderator<T>(
+ pub async fn add_channel_moderator<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::AddChannelModeratorResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
let req = helix::moderation::AddChannelModeratorRequest {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
};
Ok(self.req_post(req, helix::EmptyBody, token).await?.data)
}
/// Remove a channel moderator
- pub async fn remove_channel_moderator<T>(
+ pub async fn remove_channel_moderator<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- moderator_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ moderator_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::moderation::RemoveChannelModeratorResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
let req = helix::moderation::RemoveChannelModeratorRequest {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
};
Ok(self.req_delete(req, token).await?.data)
}
/// Get channel VIPs
- pub fn get_vips_in_channel<T>(
+ pub fn get_vips_in_channel<'b: 'a, T>(
&'a self,
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &'a T,
) -> std::pin::Pin<
Box<dyn futures::Stream<Item = Result<helix::channels::Vip, ClientError<'a, C>>> + 'a>,
@@ -840,47 +829,47 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
}
/// Add a channel vip
- pub async fn add_channel_vip<T>(
+ pub async fn add_channel_vip<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- user_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::channels::AddChannelVipResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
let req = helix::channels::AddChannelVipRequest {
- broadcaster_id: broadcaster_id.into(),
- user_id: user_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ user_id: user_id.to_cow(),
};
Ok(self.req_post(req, helix::EmptyBody, token).await?.data)
}
/// Remove a channel vip
- pub async fn remove_channel_vip<T>(
+ pub async fn remove_channel_vip<'b, T>(
&'a self,
- broadcaster_id: impl Into<&types::UserIdRef>,
- user_id: impl Into<&types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ user_id: impl types::IntoCow<'b, types::UserIdRef> + 'b,
token: &T,
) -> Result<helix::channels::RemoveChannelVipResponse, ClientError<'a, C>>
where
T: TwitchToken + ?Sized,
{
let req = helix::channels::RemoveChannelVipRequest {
- broadcaster_id: broadcaster_id.into(),
- user_id: user_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ user_id: user_id.to_cow(),
};
Ok(self.req_delete(req, token).await?.data)
}
/// Send a whisper
- pub async fn send_whisper<T>(
+ pub async fn send_whisper<'b, T>(
&'a self,
- from: impl Into<&types::UserIdRef>,
- to: impl Into<&types::UserIdRef>,
- message: impl AsRef<str>,
+ from: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ to: impl types::IntoCow<'b, types::UserIdRef> + 'b,
+ message: impl Into<&'b str>,
token: &T,
) -> Result<helix::whispers::SendWhisperResponse, ClientError<'a, C>>
where
@@ -888,8 +877,8 @@ impl<'a, C: crate::HttpClient<'a> + Sync> HelixClient<'a, C> {
{
Ok(self
.req_post(
- helix::whispers::SendWhisperRequest::new(from.into(), to.into()),
- helix::whispers::SendWhisperBody::new(message.as_ref()),
+ helix::whispers::SendWhisperRequest::new(from, to),
+ helix::whispers::SendWhisperBody::new(message.into()),
token,
)
.await?
diff --git a/src/helix/endpoints/bits/get_bits_leaderboard.rs b/src/helix/endpoints/bits/get_bits_leaderboard.rs
index 95f757c18..352408ad2 100644
--- a/src/helix/endpoints/bits/get_bits_leaderboard.rs
+++ b/src/helix/endpoints/bits/get_bits_leaderboard.rs
@@ -62,11 +62,11 @@ pub struct GetBitsLeaderboardRequest<'a> {
/// Timestamp for the period over which the returned data is aggregated. Must be in RFC 3339 format. If this is not provided, data is aggregated over the current period; e.g., the current day/week/month/year. This value is ignored if period is "all".
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub started_at: Option<&'a types::TimestampRef>,
+ pub started_at: Option<Cow<'a, types::TimestampRef>>,
/// ID of the user whose results are returned; i.e., the person who paid for the Bits.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub user_id: Option<&'a types::UserIdRef>,
+ pub user_id: Option<Cow<'a, types::UserIdRef>>,
}
impl<'a> GetBitsLeaderboardRequest<'a> {
@@ -87,17 +87,17 @@ impl<'a> GetBitsLeaderboardRequest<'a> {
}
/// Get leaderboard starting at this timestamp
- pub fn started_at(self, started_at: impl Into<&'a types::TimestampRef>) -> Self {
+ pub fn started_at(self, started_at: impl types::IntoCow<'a, types::TimestampRef> + 'a) -> Self {
Self {
- started_at: Some(started_at.into()),
+ started_at: Some(started_at.to_cow()),
..self
}
}
/// Get leaderboard where this user is included (if they are on the leaderboard)
- pub fn user_id(self, user_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn user_id(self, user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- user_id: Some(user_id.into()),
+ user_id: Some(user_id.to_cow()),
..self
}
}
diff --git a/src/helix/endpoints/bits/get_cheermotes.rs b/src/helix/endpoints/bits/get_cheermotes.rs
index 4bd577427..5685569ad 100644
--- a/src/helix/endpoints/bits/get_cheermotes.rs
+++ b/src/helix/endpoints/bits/get_cheermotes.rs
@@ -48,7 +48,7 @@ pub struct GetCheermotesRequest<'a> {
/// ID for the broadcaster who might own specialized Cheermotes.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: Option<&'a types::UserIdRef>,
+ pub broadcaster_id: Option<Cow<'a, types::UserIdRef>>,
}
impl<'a> GetCheermotesRequest<'a> {
@@ -56,9 +56,9 @@ impl<'a> GetCheermotesRequest<'a> {
pub fn new() -> Self { Self::default() }
/// Get Cheermotes in a specific broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: Some(broadcaster_id.into()),
+ broadcaster_id: Some(broadcaster_id.to_cow()),
}
}
}
diff --git a/src/helix/endpoints/bits/mod.rs b/src/helix/endpoints/bits/mod.rs
index ca5ffa5ee..2ae3d728a 100644
--- a/src/helix/endpoints/bits/mod.rs
+++ b/src/helix/endpoints/bits/mod.rs
@@ -22,6 +22,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_bits_leaderboard;
pub mod get_cheermotes;
diff --git a/src/helix/endpoints/channels/add_channel_vip.rs b/src/helix/endpoints/channels/add_channel_vip.rs
index 449acf8c4..3a7ee1b87 100644
--- a/src/helix/endpoints/channels/add_channel_vip.rs
+++ b/src/helix/endpoints/channels/add_channel_vip.rs
@@ -45,22 +45,22 @@ pub struct AddChannelVipRequest<'a> {
/// The ID of the broadcaster that’s granting VIP status to the user.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to add as a VIP in the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> AddChannelVipRequest<'a> {
/// Add a channel VIP
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- user_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- user_id: user_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ user_id: user_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/channels/get_channel_editors.rs b/src/helix/endpoints/channels/get_channel_editors.rs
index cc66f3947..737d4e07a 100644
--- a/src/helix/endpoints/channels/get_channel_editors.rs
+++ b/src/helix/endpoints/channels/get_channel_editors.rs
@@ -47,14 +47,14 @@ pub struct GetChannelEditorsRequest<'a> {
/// Broadcaster’s user ID associated with the channel.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetChannelEditorsRequest<'a> {
/// Get specified broadcasters channel editors
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/channels/get_channel_information.rs b/src/helix/endpoints/channels/get_channel_information.rs
index 2f615e65f..05817bbf4 100644
--- a/src/helix/endpoints/channels/get_channel_information.rs
+++ b/src/helix/endpoints/channels/get_channel_information.rs
@@ -47,14 +47,14 @@ pub struct GetChannelInformationRequest<'a> {
/// ID of the channel
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetChannelInformationRequest<'a> {
/// Get channel information for a specific broadcaster.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/channels/get_vips.rs b/src/helix/endpoints/channels/get_vips.rs
index ce3a5018a..9138bafd3 100644
--- a/src/helix/endpoints/channels/get_vips.rs
+++ b/src/helix/endpoints/channels/get_vips.rs
@@ -36,7 +36,6 @@
//! and parse the [`http::Response`] with [`GetVipsRequest::parse_response(None, &request.get_uri(), response)`](GetVipsRequest::parse_response)
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get VIPs](super::get_vips)
///
@@ -48,7 +47,7 @@ pub struct GetVipsRequest<'a> {
/// The ID of the broadcaster whose list of VIPs you want to get.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Filters the list for specific VIPs. To specify more than one user, include the user_id parameter for each user to get. For example, &user_id=1234&user_id=5678. The maximum number of IDs that you may specify is 100. Ignores those users in the list that aren’t VIPs.
#[cfg_attr(feature = "typed-builder", builder(default))]
#[serde(borrow)]
@@ -63,9 +62,9 @@ pub struct GetVipsRequest<'a> {
impl<'a> GetVipsRequest<'a> {
/// Get channel VIPs in channel
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
first: None,
after: None,
diff --git a/src/helix/endpoints/channels/mod.rs b/src/helix/endpoints/channels/mod.rs
index 453736ca7..b189294b1 100644
--- a/src/helix/endpoints/channels/mod.rs
+++ b/src/helix/endpoints/channels/mod.rs
@@ -24,6 +24,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod add_channel_vip;
pub mod get_channel_editors;
diff --git a/src/helix/endpoints/channels/modify_channel_information.rs b/src/helix/endpoints/channels/modify_channel_information.rs
index 60682048d..e1ddb3a6d 100644
--- a/src/helix/endpoints/channels/modify_channel_information.rs
+++ b/src/helix/endpoints/channels/modify_channel_information.rs
@@ -65,14 +65,14 @@ pub struct ModifyChannelInformationRequest<'a> {
/// ID of the channel
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> ModifyChannelInformationRequest<'a> {
/// Modify specified broadcasters channel
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
ModifyChannelInformationRequest {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
@@ -88,7 +88,7 @@ pub struct ModifyChannelInformationBody<'a> {
/// Current game ID being played on the channel. Use “0” or “” (an empty string) to unset the game.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
- pub game_id: Option<&'a types::CategoryIdRef>,
+ pub game_id: Option<Cow<'a, types::CategoryIdRef>>,
/// Language of the channel
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
@@ -112,8 +112,11 @@ impl<'a> ModifyChannelInformationBody<'a> {
pub fn new() -> Self { Default::default() }
/// Current game ID being played on the channel. Use “0” or “” (an empty string) to unset the game.
- pub fn game_id(&mut self, game_id: impl Into<&'a types::CategoryIdRef>) -> &mut Self {
- self.game_id = Some(game_id.into());
+ pub fn game_id(
+ &mut self,
+ game_id: impl types::IntoCow<'a, types::CategoryIdRef> + 'a,
+ ) -> &mut Self {
+ self.game_id = Some(game_id.to_cow());
self
}
@@ -124,7 +127,7 @@ impl<'a> ModifyChannelInformationBody<'a> {
}
/// Title of the stream. Value must not be an empty string.
- pub fn title(&'a mut self, title: impl Into<&'a str>) -> &'a mut ModifyChannelInformationBody {
+ pub fn title(&mut self, title: impl Into<&'a str>) -> &mut Self {
self.title = Some(title.into());
self
}
@@ -191,7 +194,7 @@ fn test_request() {
let req = ModifyChannelInformationRequest::broadcaster_id("0");
let body = ModifyChannelInformationBody {
- title: Some("Hello World!".into()),
+ title: Some("Hello World!"),
..Default::default()
};
diff --git a/src/helix/endpoints/channels/remove_channel_vip.rs b/src/helix/endpoints/channels/remove_channel_vip.rs
index 05fe3f973..bd7e2ddca 100644
--- a/src/helix/endpoints/channels/remove_channel_vip.rs
+++ b/src/helix/endpoints/channels/remove_channel_vip.rs
@@ -52,22 +52,22 @@ pub struct RemoveChannelVipRequest<'a> {
/// The ID of the broadcaster that’s removing VIP status from the user.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to remove as a VIP from the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> RemoveChannelVipRequest<'a> {
/// Remove channel VIP
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- user_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- user_id: user_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ user_id: user_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/channels/start_commercial.rs b/src/helix/endpoints/channels/start_commercial.rs
index 17deb5304..221c8504c 100644
--- a/src/helix/endpoints/channels/start_commercial.rs
+++ b/src/helix/endpoints/channels/start_commercial.rs
@@ -79,7 +79,7 @@ pub struct StartCommercialBody<'a> {
/// ID of the channel requesting a commercial
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Desired length of the commercial in seconds. Valid options are 30, 60, 90, 120, 150, 180.
pub length: types::CommercialLength,
}
@@ -87,11 +87,11 @@ pub struct StartCommercialBody<'a> {
impl<'a> StartCommercialBody<'a> {
/// Start a commercial in this broadcasters channel
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
length: impl Into<types::CommercialLength>,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
length: length.into(),
}
}
diff --git a/src/helix/endpoints/chat/get_channel_chat_badges.rs b/src/helix/endpoints/chat/get_channel_chat_badges.rs
index 312834301..f5a57eaff 100644
--- a/src/helix/endpoints/chat/get_channel_chat_badges.rs
+++ b/src/helix/endpoints/chat/get_channel_chat_badges.rs
@@ -50,14 +50,14 @@ pub struct GetChannelChatBadgesRequest<'a> {
/// The broadcaster whose chat badges are being requested. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetChannelChatBadgesRequest<'a> {
/// Get chat badges for the specified broadcaster.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/chat/get_channel_emotes.rs b/src/helix/endpoints/chat/get_channel_emotes.rs
index 216cf581d..183054aa6 100644
--- a/src/helix/endpoints/chat/get_channel_emotes.rs
+++ b/src/helix/endpoints/chat/get_channel_emotes.rs
@@ -50,14 +50,14 @@ pub struct GetChannelEmotesRequest<'a> {
/// The broadcaster whose emotes are being requested.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetChannelEmotesRequest<'a> {
/// Get emotes in a specific broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/chat/get_chat_settings.rs b/src/helix/endpoints/chat/get_chat_settings.rs
index 2d1704d1d..1fd19df14 100644
--- a/src/helix/endpoints/chat/get_chat_settings.rs
+++ b/src/helix/endpoints/chat/get_chat_settings.rs
@@ -65,7 +65,7 @@ pub struct GetChatSettingsRequest<'a> {
/// The ID of the broadcaster whose chat settings you want to get.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Required only to access the [`non_moderator_chat_delay`](ChatSettings::non_moderator_chat_delay)
/// or [`non_moderator_chat_delay_duration`](ChatSettings::non_moderator_chat_delay_duration) settings.
/// If you want to access these settings, you need to provide a valid [`moderator_id`](Self::moderator_id)
@@ -79,14 +79,14 @@ pub struct GetChatSettingsRequest<'a> {
/// set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub moderator_id: Option<&'a types::UserIdRef>,
+ pub moderator_id: Option<Cow<'a, types::UserIdRef>>,
}
impl<'a> GetChatSettingsRequest<'a> {
/// Get chat settings for broadcasters channel
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
moderator_id: None,
}
}
@@ -95,8 +95,11 @@ impl<'a> GetChatSettingsRequest<'a> {
///
/// Required only to access the [`non_moderator_chat_delay`](ChatSettings::non_moderator_chat_delay)
/// or [`non_moderator_chat_delay_duration`](ChatSettings::non_moderator_chat_delay_duration) settings.
- pub fn moderator_id(mut self, moderator_id: impl Into<&'a types::UserIdRef>) -> Self {
- self.moderator_id = Some(moderator_id.into());
+ pub fn moderator_id(
+ mut self,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ ) -> Self {
+ self.moderator_id = Some(moderator_id.to_cow());
self
}
}
diff --git a/src/helix/endpoints/chat/get_chatters.rs b/src/helix/endpoints/chat/get_chatters.rs
index ff95f10f2..529a1f81c 100644
--- a/src/helix/endpoints/chat/get_chatters.rs
+++ b/src/helix/endpoints/chat/get_chatters.rs
@@ -56,13 +56,13 @@ pub struct GetChattersRequest<'a> {
/// The ID of the broadcaster whose list of chatters you want to get.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the moderator or the specified broadcaster that’s requesting the list of chatters. This ID must match the user ID associated with the user access token.
///
/// The moderator must have permission to moderate the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
/// The maximum number of items to return per page in the response. The minimum page size is 1 item per page and the maximum is 1,000. The default is 100.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
pub first: Option<usize>,
@@ -78,12 +78,12 @@ impl<'a> GetChattersRequest<'a> {
///
/// The moderator has to be the token owner and can moderate the chat
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
first: None,
after: None,
}
diff --git a/src/helix/endpoints/chat/get_emote_sets.rs b/src/helix/endpoints/chat/get_emote_sets.rs
index 91ff720d9..682a9f1f4 100644
--- a/src/helix/endpoints/chat/get_emote_sets.rs
+++ b/src/helix/endpoints/chat/get_emote_sets.rs
@@ -40,7 +40,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Channel Emotes](super::get_emote_sets)
///
diff --git a/src/helix/endpoints/chat/get_user_chat_color.rs b/src/helix/endpoints/chat/get_user_chat_color.rs
index 97884c27d..3b76bfe51 100644
--- a/src/helix/endpoints/chat/get_user_chat_color.rs
+++ b/src/helix/endpoints/chat/get_user_chat_color.rs
@@ -40,7 +40,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Chatters](super::get_user_chat_color)
///
diff --git a/src/helix/endpoints/chat/mod.rs b/src/helix/endpoints/chat/mod.rs
index 786af8be3..c3df5f1d0 100644
--- a/src/helix/endpoints/chat/mod.rs
+++ b/src/helix/endpoints/chat/mod.rs
@@ -5,6 +5,7 @@ use crate::{
types::{self, EmoteUrlBuilder},
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_channel_chat_badges;
pub mod get_channel_emotes;
diff --git a/src/helix/endpoints/chat/send_chat_announcement.rs b/src/helix/endpoints/chat/send_chat_announcement.rs
index a9f1fcbf2..422662ed1 100644
--- a/src/helix/endpoints/chat/send_chat_announcement.rs
+++ b/src/helix/endpoints/chat/send_chat_announcement.rs
@@ -66,24 +66,24 @@ pub struct SendChatAnnouncementRequest<'a> {
/// The ID of the broadcaster that owns the chat room to send the announcement to.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user who has permission to moderate the broadcaster’s chat room.
///
/// This ID must match the user ID in the OAuth token, which can be a moderator or the broadcaster.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
impl<'a> SendChatAnnouncementRequest<'a> {
/// Send announcement in channel as this moderator
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/chat/update_chat_settings.rs b/src/helix/endpoints/chat/update_chat_settings.rs
index f7f04163f..2df3eda4a 100644
--- a/src/helix/endpoints/chat/update_chat_settings.rs
+++ b/src/helix/endpoints/chat/update_chat_settings.rs
@@ -71,26 +71,26 @@ pub struct UpdateChatSettingsRequest<'a> {
/// The ID of the broadcaster whose chat settings you want to update.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room.
/// This ID must match the user ID associated with the user OAuth token.
///
/// If the broadcaster is making the update, also set this parameter to the broadcaster’s ID.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
///FIXME: The moderator_id parameter is redundant, we should make this a client ext function
impl<'a> UpdateChatSettingsRequest<'a> {
/// Update the chat settings for the specified broadcaster as the specified moderator
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/chat/update_user_chat_color.rs b/src/helix/endpoints/chat/update_user_chat_color.rs
index 8b2e12ba3..6e976fd57 100644
--- a/src/helix/endpoints/chat/update_user_chat_color.rs
+++ b/src/helix/endpoints/chat/update_user_chat_color.rs
@@ -53,21 +53,21 @@ pub struct UpdateUserChatColorRequest<'a> {
/// The ID of the user whose chat color you want to update.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
/// The color to use for the user’s name in chat.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
- #[serde(borrow = "'static")]
- pub color: types::NamedUserColor<'static>,
+ #[serde(borrow)]
+ pub color: types::NamedUserColor<'a>,
}
impl<'a> UpdateUserChatColorRequest<'a> {
/// Update the users chat color
pub fn new(
- user_id: impl Into<&'a types::UserIdRef>,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
color: types::NamedUserColor<'static>,
) -> Self {
Self {
- user_id: user_id.into(),
+ user_id: user_id.to_cow(),
color,
}
}
diff --git a/src/helix/endpoints/clips/get_clips.rs b/src/helix/endpoints/clips/get_clips.rs
index 92c103b82..f304e27fe 100644
--- a/src/helix/endpoints/clips/get_clips.rs
+++ b/src/helix/endpoints/clips/get_clips.rs
@@ -39,7 +39,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Clips](super::get_clips)
///
@@ -51,11 +50,11 @@ pub struct GetClipsRequest<'a> {
/// ID of the broadcaster for whom clips are returned. The number of clips returned is determined by the first query-string parameter (default: 20). Results are ordered by view count.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: Option<&'a types::UserIdRef>,
+ pub broadcaster_id: Option<Cow<'a, types::UserIdRef>>,
/// ID of the game for which clips are returned. The number of clips returned is determined by the first query-string parameter (default: 20). Results are ordered by view count.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub game_id: Option<&'a types::CategoryIdRef>,
+ pub game_id: Option<Cow<'a, types::CategoryIdRef>>,
// FIXME: add types::ClipId
/// ID of the clip being queried. Limit: 100.
#[cfg_attr(feature = "typed-builder", builder(default))]
@@ -72,14 +71,14 @@ pub struct GetClipsRequest<'a> {
/// Ending date/time for returned clips, in RFC3339 format. (Note that the seconds value is ignored.) If this is specified, started_at also must be specified; otherwise, the time period is ignored.
#[cfg_attr(feature = "typed-builder", builder(default))]
#[serde(borrow)]
- pub ended_at: Option<&'a types::TimestampRef>,
+ pub ended_at: Option<Cow<'a, types::TimestampRef>>,
/// Maximum number of objects to return. Maximum: 100. Default: 20.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
pub first: Option<usize>,
/// Starting date/time for returned clips, in RFC3339 format. (Note that the seconds value is ignored.) If this is specified, ended_at also should be specified; otherwise, the ended_at date/time will be 1 week after the started_at value.
#[cfg_attr(feature = "typed-builder", builder(default))]
#[serde(borrow)]
- pub started_at: Option<&'a types::TimestampRef>,
+ pub started_at: Option<Cow<'a, types::TimestampRef>>,
}
impl<'a> GetClipsRequest<'a> {
@@ -102,17 +101,17 @@ impl<'a> GetClipsRequest<'a> {
}
/// Broadcaster for whom clips are returned.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: Some(broadcaster_id.into()),
+ broadcaster_id: Some(broadcaster_id.to_cow()),
..Self::empty()
}
}
/// Game for which clips are returned.
- pub fn game_id(game_id: impl Into<&'a types::CategoryIdRef>) -> Self {
+ pub fn game_id(game_id: impl types::IntoCow<'a, types::CategoryIdRef> + 'a) -> Self {
Self {
- game_id: Some(game_id.into()),
+ game_id: Some(game_id.to_cow()),
..Self::empty()
}
}
@@ -126,14 +125,20 @@ impl<'a> GetClipsRequest<'a> {
}
/// Ending date/time for the returned clips
- pub fn started_at(&mut self, started_at: impl Into<&'a types::TimestampRef>) -> &mut Self {
- self.started_at = Some(started_at.into());
+ pub fn started_at(
+ &mut self,
+ started_at: impl types::IntoCow<'a, types::TimestampRef> + 'a,
+ ) -> &mut Self {
+ self.started_at = Some(started_at.to_cow());
self
}
/// Ending date/time for the returned clips
- pub fn ended_at(&mut self, ended_at: impl Into<&'a types::TimestampRef>) -> &mut Self {
- self.ended_at = Some(ended_at.into());
+ pub fn ended_at(
+ &mut self,
+ ended_at: impl types::IntoCow<'a, types::TimestampRef> + 'a,
+ ) -> &mut Self {
+ self.ended_at = Some(ended_at.to_cow());
self
}
}
diff --git a/src/helix/endpoints/clips/mod.rs b/src/helix/endpoints/clips/mod.rs
index b05269dce..95621da94 100644
--- a/src/helix/endpoints/clips/mod.rs
+++ b/src/helix/endpoints/clips/mod.rs
@@ -24,6 +24,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_clips;
diff --git a/src/helix/endpoints/eventsub/delete_eventsub_subscription.rs b/src/helix/endpoints/eventsub/delete_eventsub_subscription.rs
index fd2a168f7..97c8f1729 100644
--- a/src/helix/endpoints/eventsub/delete_eventsub_subscription.rs
+++ b/src/helix/endpoints/eventsub/delete_eventsub_subscription.rs
@@ -13,12 +13,14 @@ pub struct DeleteEventSubSubscriptionRequest<'a> {
/// The subscription ID for the subscription you want to delete.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::EventSubIdRef,
+ pub id: Cow<'a, types::EventSubIdRef>,
}
impl<'a> DeleteEventSubSubscriptionRequest<'a> {
/// Delete this eventsub subscription.
- pub fn id(id: impl Into<&'a types::EventSubIdRef>) -> Self { Self { id: id.into() } }
+ pub fn id(id: impl types::IntoCow<'a, types::EventSubIdRef> + 'a) -> Self {
+ Self { id: id.to_cow() }
+ }
}
impl Request for DeleteEventSubSubscriptionRequest<'_> {
diff --git a/src/helix/endpoints/eventsub/get_eventsub_subscriptions.rs b/src/helix/endpoints/eventsub/get_eventsub_subscriptions.rs
index 63a187707..824d172a0 100644
--- a/src/helix/endpoints/eventsub/get_eventsub_subscriptions.rs
+++ b/src/helix/endpoints/eventsub/get_eventsub_subscriptions.rs
@@ -23,7 +23,7 @@ pub struct GetEventSubSubscriptionsRequest<'a> {
/// matches a user ID that you specified in the Condition object when you created the subscription.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub user_id: Option<&'a types::UserIdRef>,
+ pub user_id: Option<Cow<'a, types::UserIdRef>>,
// FIXME: https://github.com/twitchdev/issues/issues/272
/// Cursor for forward pagination
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
diff --git a/src/helix/endpoints/eventsub/mod.rs b/src/helix/endpoints/eventsub/mod.rs
index 30fee3f20..065da66c5 100644
--- a/src/helix/endpoints/eventsub/mod.rs
+++ b/src/helix/endpoints/eventsub/mod.rs
@@ -5,6 +5,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod create_eventsub_subscription;
pub mod delete_eventsub_subscription;
diff --git a/src/helix/endpoints/games/get_games.rs b/src/helix/endpoints/games/get_games.rs
index 69911ffbb..e5ed6e484 100644
--- a/src/helix/endpoints/games/get_games.rs
+++ b/src/helix/endpoints/games/get_games.rs
@@ -36,7 +36,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Games](super::get_games)
///
diff --git a/src/helix/endpoints/games/mod.rs b/src/helix/endpoints/games/mod.rs
index a4a675d39..8eb890091 100644
--- a/src/helix/endpoints/games/mod.rs
+++ b/src/helix/endpoints/games/mod.rs
@@ -3,8 +3,8 @@ use crate::{
helix::{self, Request},
types,
};
-
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_games;
pub mod get_top_games;
diff --git a/src/helix/endpoints/goals/get_creator_goals.rs b/src/helix/endpoints/goals/get_creator_goals.rs
index 0477f24cc..01b569939 100644
--- a/src/helix/endpoints/goals/get_creator_goals.rs
+++ b/src/helix/endpoints/goals/get_creator_goals.rs
@@ -50,7 +50,7 @@ pub struct GetCreatorGoalsRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub cursor: Option<helix::Cursor>,
@@ -65,9 +65,9 @@ pub struct GetCreatorGoalsRequest<'a> {
impl<'a> GetCreatorGoalsRequest<'a> {
/// Gets the broadcaster’s list of active goals.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
cursor: Default::default(),
first: Default::default(),
id: Default::default(),
diff --git a/src/helix/endpoints/goals/mod.rs b/src/helix/endpoints/goals/mod.rs
index d3afd1757..768067b13 100644
--- a/src/helix/endpoints/goals/mod.rs
+++ b/src/helix/endpoints/goals/mod.rs
@@ -5,8 +5,8 @@ use crate::{
helix::{self, Request},
types,
};
-
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_creator_goals;
diff --git a/src/helix/endpoints/hypetrain/get_hypetrain_events.rs b/src/helix/endpoints/hypetrain/get_hypetrain_events.rs
index e59029114..aebc34685 100644
--- a/src/helix/endpoints/hypetrain/get_hypetrain_events.rs
+++ b/src/helix/endpoints/hypetrain/get_hypetrain_events.rs
@@ -51,7 +51,7 @@ pub struct GetHypeTrainEventsRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub cursor: Option<helix::Cursor>,
@@ -70,9 +70,9 @@ pub struct GetHypeTrainEventsRequest<'a> {
impl<'a> GetHypeTrainEventsRequest<'a> {
/// Get hypetrain evens
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
cursor: Default::default(),
first: Default::default(),
id: Default::default(),
diff --git a/src/helix/endpoints/hypetrain/mod.rs b/src/helix/endpoints/hypetrain/mod.rs
index ac9510f34..9dd8d971d 100644
--- a/src/helix/endpoints/hypetrain/mod.rs
+++ b/src/helix/endpoints/hypetrain/mod.rs
@@ -5,8 +5,8 @@ use crate::{
helix::{self, Request},
types,
};
-
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_hypetrain_events;
diff --git a/src/helix/endpoints/moderation/add_blocked_term.rs b/src/helix/endpoints/moderation/add_blocked_term.rs
index 323a844f0..06debda8c 100644
--- a/src/helix/endpoints/moderation/add_blocked_term.rs
+++ b/src/helix/endpoints/moderation/add_blocked_term.rs
@@ -63,24 +63,24 @@ pub struct AddBlockedTermRequest<'a> {
/// The ID of the broadcaster that owns the list of blocked terms.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room. This ID must match the user ID associated with the user OAuth token.
///
/// If the broadcaster wants to add the blocked term (instead of having the moderator do it), set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
impl<'a> AddBlockedTermRequest<'a> {
/// Where to add blocked term
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/moderation/add_channel_moderator.rs b/src/helix/endpoints/moderation/add_channel_moderator.rs
index 660ada22e..411d5e483 100644
--- a/src/helix/endpoints/moderation/add_channel_moderator.rs
+++ b/src/helix/endpoints/moderation/add_channel_moderator.rs
@@ -53,22 +53,22 @@ pub struct AddChannelModeratorRequest<'a> {
/// The ID of the broadcaster that owns the chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to add as a moderator in the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
impl<'a> AddChannelModeratorRequest<'a> {
/// Add moderator on channel
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/moderation/ban_user.rs b/src/helix/endpoints/moderation/ban_user.rs
index 2cbcebcb0..b123fb313 100644
--- a/src/helix/endpoints/moderation/ban_user.rs
+++ b/src/helix/endpoints/moderation/ban_user.rs
@@ -63,7 +63,7 @@ pub struct BanUserRequest<'a> {
/// The ID of the broadcaster whose chat room the user is being banned from.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room.
/// This ID must match the user ID associated with the user OAuth token.
///
@@ -71,18 +71,18 @@ pub struct BanUserRequest<'a> {
/// set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
impl<'a> BanUserRequest<'a> {
/// Ban a user on this channel
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
@@ -111,20 +111,20 @@ pub struct BanUserBody<'a> {
/// The ID of the user to ban or put in a timeout.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> BanUserBody<'a> {
/// Create a new [`BanUserBody`]
pub fn new(
- user_id: impl Into<&'a types::UserIdRef>,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
reason: &'a str,
duration: impl Into<Option<u32>>,
) -> Self {
Self {
duration: duration.into(),
reason,
- user_id: user_id.into(),
+ user_id: user_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/moderation/check_automod_status.rs b/src/helix/endpoints/moderation/check_automod_status.rs
index 599ac286a..224057535 100644
--- a/src/helix/endpoints/moderation/check_automod_status.rs
+++ b/src/helix/endpoints/moderation/check_automod_status.rs
@@ -69,14 +69,14 @@ pub struct CheckAutoModStatusRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> CheckAutoModStatusRequest<'a> {
/// Check automod status in this broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
@@ -91,7 +91,7 @@ pub struct CheckAutoModStatusBody<'a> {
/// Developer-generated identifier for mapping messages to results.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub msg_id: &'a types::MsgIdRef,
+ pub msg_id: Cow<'a, types::MsgIdRef>,
/// Message text.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
@@ -103,14 +103,14 @@ pub struct CheckAutoModStatusBody<'a> {
builder(setter(into, strip_option), default)
)]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
- pub user_id: Option<&'a types::UserIdRef>,
+ pub user_id: Option<Cow<'a, types::UserIdRef>>,
}
impl<'a> CheckAutoModStatusBody<'a> {
/// Create a new [`CheckAutoModStatusBody`]
- pub fn new(msg_id: impl Into<&'a types::MsgIdRef>, msg_text: &'a str) -> Self {
+ pub fn new(msg_id: impl types::IntoCow<'a, types::MsgIdRef> + 'a, msg_text: &'a str) -> Self {
Self {
- msg_id: msg_id.into(),
+ msg_id: msg_id.to_cow(),
msg_text,
user_id: None,
}
diff --git a/src/helix/endpoints/moderation/delete_chat_messages.rs b/src/helix/endpoints/moderation/delete_chat_messages.rs
index dd345803f..a1d1c12ae 100644
--- a/src/helix/endpoints/moderation/delete_chat_messages.rs
+++ b/src/helix/endpoints/moderation/delete_chat_messages.rs
@@ -53,13 +53,13 @@ pub struct DeleteChatMessagesRequest<'a> {
/// The ID of the broadcaster that owns the chat room to remove messages from.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room.
///
/// This ID must match the user ID in the OAuth token. If the broadcaster wants to remove messages themselves, set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
/// The ID of the message to remove.
///
/// The id tag in the PRIVMSG contains the message’s ID (see [PRIVMSG Tags](https://dev.twitch.tv/docs/irc/tags#privmsg-tags)).
@@ -73,25 +73,25 @@ pub struct DeleteChatMessagesRequest<'a> {
/// If not specified, the request removes all messages in the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub message_id: Option<&'a types::MsgIdRef>,
+ pub message_id: Option<Cow<'a, types::MsgIdRef>>,
}
impl<'a> DeleteChatMessagesRequest<'a> {
/// Remove chat message(s)
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
message_id: None,
}
}
/// A specific message to remove
- pub fn message_id(mut self, message_id: impl Into<&'a types::MsgIdRef>) -> Self {
- self.message_id = Some(message_id.into());
+ pub fn message_id(mut self, message_id: impl types::IntoCow<'a, types::MsgIdRef> + 'a) -> Self {
+ self.message_id = Some(message_id.to_cow());
self
}
}
diff --git a/src/helix/endpoints/moderation/get_banned_users.rs b/src/helix/endpoints/moderation/get_banned_users.rs
index 0efa28fd3..fefb12daa 100644
--- a/src/helix/endpoints/moderation/get_banned_users.rs
+++ b/src/helix/endpoints/moderation/get_banned_users.rs
@@ -39,7 +39,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Banned Users](super::get_banned_users)
///
@@ -51,7 +50,7 @@ pub struct GetBannedUsersRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Filters the results and only returns a status object for users who are banned in this channel and have a matching user_id.
/// Format: Repeated Query Parameter, eg. /moderation/banned?broadcaster_id=1&user_id=2&user_id=3
/// Maximum: 100
@@ -72,9 +71,9 @@ pub struct GetBannedUsersRequest<'a> {
impl<'a> GetBannedUsersRequest<'a> {
/// Get banned users in a broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
after: Default::default(),
before: Default::default(),
diff --git a/src/helix/endpoints/moderation/get_blocked_terms.rs b/src/helix/endpoints/moderation/get_blocked_terms.rs
index 5cf96a7c6..d4e51787d 100644
--- a/src/helix/endpoints/moderation/get_blocked_terms.rs
+++ b/src/helix/endpoints/moderation/get_blocked_terms.rs
@@ -52,12 +52,12 @@ pub struct GetBlockedTerms<'a> {
/// The ID of the broadcaster whose blocked terms you’re getting.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room. This ID must match the user ID associated with the user OAuth token.
/// If the broadcaster wants to get their own block terms (instead of having the moderator do it), set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
/// The maximum number of blocked terms to return per page in the response. The minimum page size is 1 blocked term per page and the maximum is 100. The default is 20.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
pub first: Option<u32>,
@@ -69,12 +69,12 @@ pub struct GetBlockedTerms<'a> {
impl<'a> GetBlockedTerms<'a> {
/// Get blocked terms in a broadcasters channel as specified moderator
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
after: Default::default(),
first: Default::default(),
}
diff --git a/src/helix/endpoints/moderation/get_moderators.rs b/src/helix/endpoints/moderation/get_moderators.rs
index 71b301c44..5f04d2e2d 100644
--- a/src/helix/endpoints/moderation/get_moderators.rs
+++ b/src/helix/endpoints/moderation/get_moderators.rs
@@ -38,7 +38,6 @@
//! and parse the [`http::Response`] with [`GetModeratorsRequest::parse_response(None, &request.get_uri(), response)`](GetModeratorsRequest::parse_response)
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
// Format: Repeated Query Parameter, eg. /moderation/banned?broadcaster_id=1&user_id=2&user_id=3
// Maximum: 100
@@ -52,7 +51,7 @@ pub struct GetModeratorsRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Filters the results and only returns a status object for users who are moderators in this channel and have a matching user_id.
#[cfg_attr(feature = "typed-builder", builder(setter(into), default))]
#[serde(borrow)]
@@ -67,9 +66,9 @@ pub struct GetModeratorsRequest<'a> {
impl<'a> GetModeratorsRequest<'a> {
/// Get moderators in a broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
after: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/moderation/manage_held_automod_messages.rs b/src/helix/endpoints/moderation/manage_held_automod_messages.rs
index f2feaf7e0..f805f0b33 100644
--- a/src/helix/endpoints/moderation/manage_held_automod_messages.rs
+++ b/src/helix/endpoints/moderation/manage_held_automod_messages.rs
@@ -83,11 +83,11 @@ pub struct ManageHeldAutoModMessagesBody<'a> {
/// The moderator who is approving or rejecting the held message. Must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
/// ID of the message to be allowed or denied. These message IDs are retrieved from IRC or PubSub. Only one message ID can be provided.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub msg_id: &'a types::MsgIdRef,
+ pub msg_id: Cow<'a, types::MsgIdRef>,
/// The action to take for the message. Must be "ALLOW" or "DENY".
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
pub action: AutoModAction,
@@ -104,13 +104,13 @@ impl<'a> ManageHeldAutoModMessagesBody<'a> {
/// let body = ManageHeldAutoModMessagesBody::new("1234", "5678", true);
/// ```
pub fn new(
- user_id: impl Into<&'a types::UserIdRef>,
- msg_id: impl Into<&'a types::MsgIdRef>,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ msg_id: impl types::IntoCow<'a, types::MsgIdRef> + 'a,
action: impl Into<AutoModAction>,
) -> Self {
Self {
- user_id: user_id.into(),
- msg_id: msg_id.into(),
+ user_id: user_id.to_cow(),
+ msg_id: msg_id.to_cow(),
action: action.into(),
}
}
diff --git a/src/helix/endpoints/moderation/mod.rs b/src/helix/endpoints/moderation/mod.rs
index 572167bc2..04b7e49b3 100644
--- a/src/helix/endpoints/moderation/mod.rs
+++ b/src/helix/endpoints/moderation/mod.rs
@@ -6,6 +6,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod add_blocked_term;
pub mod add_channel_moderator;
diff --git a/src/helix/endpoints/moderation/remove_blocked_term.rs b/src/helix/endpoints/moderation/remove_blocked_term.rs
index a1dfd3474..3f983cc87 100644
--- a/src/helix/endpoints/moderation/remove_blocked_term.rs
+++ b/src/helix/endpoints/moderation/remove_blocked_term.rs
@@ -53,29 +53,29 @@ pub struct RemoveBlockedTermRequest<'a> {
/// The ID of the broadcaster that owns the list of blocked terms.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room. This ID must match the user ID associated with the user OAuth token.
/// If the broadcaster wants to delete the blocked term (instead of having the moderator do it), set this parameter to the broadcaster’s ID, too.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
/// The ID of the blocked term you want to delete.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::BlockedTermIdRef,
+ pub id: Cow<'a, types::BlockedTermIdRef>,
}
impl<'a> RemoveBlockedTermRequest<'a> {
/// Remove blocked term
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::BlockedTermIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::BlockedTermIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
+ id: id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/moderation/remove_channel_moderator.rs b/src/helix/endpoints/moderation/remove_channel_moderator.rs
index d2056d52e..8bd0d781e 100644
--- a/src/helix/endpoints/moderation/remove_channel_moderator.rs
+++ b/src/helix/endpoints/moderation/remove_channel_moderator.rs
@@ -53,22 +53,22 @@ pub struct RemoveChannelModeratorRequest<'a> {
/// The ID of the broadcaster that owns the chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to remove as a moderator from the broadcaster’s chat room.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
}
impl<'a> RemoveChannelModeratorRequest<'a> {
/// Remove moderator
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/moderation/unban_user.rs b/src/helix/endpoints/moderation/unban_user.rs
index 33e7a15a5..a841d61f7 100644
--- a/src/helix/endpoints/moderation/unban_user.rs
+++ b/src/helix/endpoints/moderation/unban_user.rs
@@ -55,28 +55,28 @@ pub struct UnbanUserRequest<'a> {
/// The ID of the broadcaster whose chat room the user is banned from chatting in.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of a user that has permission to moderate the broadcaster’s chat room. This ID must match the user ID associated with the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub moderator_id: &'a types::UserIdRef,
+ pub moderator_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to remove the ban or timeout from.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> UnbanUserRequest<'a> {
/// Remove the ban or timeout that was placed on the specified user.
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- moderator_id: impl Into<&'a types::UserIdRef>,
- user_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ moderator_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- moderator_id: moderator_id.into(),
- user_id: user_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ moderator_id: moderator_id.to_cow(),
+ user_id: user_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/points/create_custom_rewards.rs b/src/helix/endpoints/points/create_custom_rewards.rs
index 647533e1e..fe8292eb5 100644
--- a/src/helix/endpoints/points/create_custom_rewards.rs
+++ b/src/helix/endpoints/points/create_custom_rewards.rs
@@ -67,14 +67,14 @@ pub struct CreateCustomRewardRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> CreateCustomRewardRequest<'a> {
/// Channel to create reward on
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/points/delete_custom_reward.rs b/src/helix/endpoints/points/delete_custom_reward.rs
index ada2f8eeb..e22f04dda 100644
--- a/src/helix/endpoints/points/delete_custom_reward.rs
+++ b/src/helix/endpoints/points/delete_custom_reward.rs
@@ -52,22 +52,22 @@ pub struct DeleteCustomRewardRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of the Custom Reward to delete, must match a Custom Reward on broadcaster_id’s channel.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::RewardIdRef,
+ pub id: Cow<'a, types::RewardIdRef>,
}
impl<'a> DeleteCustomRewardRequest<'a> {
/// Reward to delete
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::RewardIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::RewardIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/points/get_custom_reward.rs b/src/helix/endpoints/points/get_custom_reward.rs
index c67c01d9a..8c5dfcc18 100644
--- a/src/helix/endpoints/points/get_custom_reward.rs
+++ b/src/helix/endpoints/points/get_custom_reward.rs
@@ -42,7 +42,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Custom Reward](super::get_custom_reward)
///
@@ -54,7 +53,7 @@ pub struct GetCustomRewardRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// When used, this parameter filters the results and only returns reward objects for the Custom Rewards with matching ID. Maximum: 50
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
@@ -66,9 +65,9 @@ pub struct GetCustomRewardRequest<'a> {
impl<'a> GetCustomRewardRequest<'a> {
/// Rewards on this broadcasters channel
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
id: Cow::Borrowed(&[]),
only_manageable_rewards: Default::default(),
}
diff --git a/src/helix/endpoints/points/get_custom_reward_redemption.rs b/src/helix/endpoints/points/get_custom_reward_redemption.rs
index 1901aa423..34dedbf12 100644
--- a/src/helix/endpoints/points/get_custom_reward_redemption.rs
+++ b/src/helix/endpoints/points/get_custom_reward_redemption.rs
@@ -55,12 +55,12 @@ pub struct GetCustomRewardRedemptionRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// When ID is not provided, this parameter returns paginated Custom Reward Redemption objects for redemptions of the Custom Reward with ID reward_id
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub reward_id: Option<&'a types::RewardIdRef>,
+ pub reward_id: Option<Cow<'a, types::RewardIdRef>>,
/// When id is not provided, this param is required and filters the paginated Custom Reward Redemption objects for redemptions with the matching status. Can be one of UNFULFILLED, FULFILLED or CANCELED
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
@@ -77,9 +77,9 @@ pub struct GetCustomRewardRedemptionRequest<'a> {
impl<'a> GetCustomRewardRedemptionRequest<'a> {
/// Reward to fetch
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
reward_id: None,
status: Default::default(),
after: Default::default(),
@@ -88,8 +88,11 @@ impl<'a> GetCustomRewardRedemptionRequest<'a> {
}
/// Specific reward to query
- pub fn reward_id(mut self, reward_id: impl Into<&'a types::RewardIdRef>) -> Self {
- self.reward_id = Some(reward_id.into());
+ pub fn reward_id(
+ mut self,
+ reward_id: impl types::IntoCow<'a, types::RewardIdRef> + 'a,
+ ) -> Self {
+ self.reward_id = Some(reward_id.to_cow());
self
}
diff --git a/src/helix/endpoints/points/mod.rs b/src/helix/endpoints/points/mod.rs
index 2faf987d1..891500019 100644
--- a/src/helix/endpoints/points/mod.rs
+++ b/src/helix/endpoints/points/mod.rs
@@ -25,6 +25,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod create_custom_rewards;
pub mod delete_custom_reward;
diff --git a/src/helix/endpoints/points/update_custom_reward.rs b/src/helix/endpoints/points/update_custom_reward.rs
index 4f4bed859..194a4db73 100644
--- a/src/helix/endpoints/points/update_custom_reward.rs
+++ b/src/helix/endpoints/points/update_custom_reward.rs
@@ -73,22 +73,22 @@ pub struct UpdateCustomRewardRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of the Custom Reward to update, must match a Custom Reward on broadcaster_id’s channel.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::RewardIdRef,
+ pub id: Cow<'a, types::RewardIdRef>,
}
impl<'a> UpdateCustomRewardRequest<'a> {
/// Update a Custom Reward created on the broadcaster's channel
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::RewardIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::RewardIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/points/update_redemption_status.rs b/src/helix/endpoints/points/update_redemption_status.rs
index 8c6a8fa37..94d611c98 100644
--- a/src/helix/endpoints/points/update_redemption_status.rs
+++ b/src/helix/endpoints/points/update_redemption_status.rs
@@ -79,30 +79,30 @@ pub struct UpdateRedemptionStatusRequest<'a> {
/// Provided broadcaster_id must match the user_id in the auth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of the Custom Reward the redemptions to be updated are for.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub reward_id: &'a types::RewardIdRef,
+ pub reward_id: Cow<'a, types::RewardIdRef>,
/// ID of the Custom Reward Redemption to update, must match a Custom Reward Redemption on broadcaster_id’s channel
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::RedemptionIdRef,
+ pub id: Cow<'a, types::RedemptionIdRef>,
}
impl<'a> UpdateRedemptionStatusRequest<'a> {
/// Update the status of Custom Reward Redemption object on a channel that are in the UNFULFILLED status.
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- reward_id: impl Into<&'a types::RewardIdRef>,
- id: impl Into<&'a types::RedemptionIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ reward_id: impl types::IntoCow<'a, types::RewardIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::RedemptionIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- reward_id: reward_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ reward_id: reward_id.to_cow(),
+ id: id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/polls/create_poll.rs b/src/helix/endpoints/polls/create_poll.rs
index c3a01a0b6..0ca12b744 100644
--- a/src/helix/endpoints/polls/create_poll.rs
+++ b/src/helix/endpoints/polls/create_poll.rs
@@ -66,11 +66,10 @@
//! You can also get the [`http::Request`] with [`request.create_request(&token, &client_id)`](helix::RequestPost::create_request)
//! and parse the [`http::Response`] with [`CreatePollRequest::parse_response(None, &request.get_uri(), response)`](CreatePollRequest::parse_response)
-use std::borrow::Cow;
-use std::marker::PhantomData;
-
use super::*;
use helix::RequestPost;
+use std::marker::PhantomData;
+
/// Query Parameters for [Create Poll](super::create_poll)
///
/// [`create-poll`](https://dev.twitch.tv/docs/api/reference#create-poll)
@@ -98,7 +97,7 @@ pub struct CreatePollBody<'a> {
/// The broadcaster running polls. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Question displayed for the poll. Maximum: 60 characters.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
@@ -145,13 +144,13 @@ impl<'a> CreatePollBody<'a> {
/// Poll settings
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
title: &'a str,
duration: i64,
choices: impl Into<Cow<'a, [NewPollChoice<'a>]>>,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
title,
duration,
choices: choices.into(),
diff --git a/src/helix/endpoints/polls/end_poll.rs b/src/helix/endpoints/polls/end_poll.rs
index 44726ef72..cd166a896 100644
--- a/src/helix/endpoints/polls/end_poll.rs
+++ b/src/helix/endpoints/polls/end_poll.rs
@@ -87,11 +87,11 @@ pub struct EndPollBody<'a> {
/// The broadcaster running polls. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of the poll.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::PollIdRef,
+ pub id: Cow<'a, types::PollIdRef>,
/// The poll status to be set.
///
/// Valid values:
@@ -103,13 +103,13 @@ pub struct EndPollBody<'a> {
impl<'a> EndPollBody<'a> {
/// End a poll that is currently active.
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::PollIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::PollIdRef> + 'a,
status: PollStatus,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
status,
}
}
diff --git a/src/helix/endpoints/polls/get_polls.rs b/src/helix/endpoints/polls/get_polls.rs
index a481afe82..dc89fe82d 100644
--- a/src/helix/endpoints/polls/get_polls.rs
+++ b/src/helix/endpoints/polls/get_polls.rs
@@ -39,7 +39,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
pub use types::{PollChoice, PollStatus};
/// Query Parameters for [Get polls](super::get_polls)
@@ -52,7 +51,7 @@ pub struct GetPollsRequest<'a> {
/// The broadcaster running polls. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of a poll. Filters results to one or more specific polls. Not providing one or more IDs will return the full list of polls for the authenticated channel.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
@@ -67,9 +66,9 @@ pub struct GetPollsRequest<'a> {
impl<'a> GetPollsRequest<'a> {
/// The broadcaster running polls.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
id: Default::default(),
after: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/polls/mod.rs b/src/helix/endpoints/polls/mod.rs
index 7e4316141..2f4bdf2f7 100644
--- a/src/helix/endpoints/polls/mod.rs
+++ b/src/helix/endpoints/polls/mod.rs
@@ -6,6 +6,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod create_poll;
pub mod end_poll;
diff --git a/src/helix/endpoints/predictions/create_prediction.rs b/src/helix/endpoints/predictions/create_prediction.rs
index d0415fe89..57b501d45 100644
--- a/src/helix/endpoints/predictions/create_prediction.rs
+++ b/src/helix/endpoints/predictions/create_prediction.rs
@@ -93,7 +93,7 @@ pub struct CreatePredictionBody<'a> {
/// The broadcaster running Predictions. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Title for the Prediction. Maximum: 45 characters.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
@@ -107,13 +107,13 @@ pub struct CreatePredictionBody<'a> {
impl<'a> CreatePredictionBody<'a> {
/// Create a Channel Points Prediction for a specific Twitch channel.
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
title: &'a str,
outcomes: (NewPredictionOutcome<'a>, NewPredictionOutcome<'a>),
prediction_window: i64,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
title,
outcomes,
prediction_window,
diff --git a/src/helix/endpoints/predictions/end_prediction.rs b/src/helix/endpoints/predictions/end_prediction.rs
index 05dcc0028..0514c91f0 100644
--- a/src/helix/endpoints/predictions/end_prediction.rs
+++ b/src/helix/endpoints/predictions/end_prediction.rs
@@ -86,11 +86,11 @@ pub struct EndPredictionBody<'a> {
/// The broadcaster running predictions. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of the prediction.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::PredictionIdRef,
+ pub id: Cow<'a, types::PredictionIdRef>,
/// The Prediction status to be set. Valid values:
///
/// [`RESOLVED`](types::PredictionStatus): A winning outcome has been chosen and the Channel Points have been distributed to the users who predicted the correct outcome.
@@ -100,19 +100,19 @@ pub struct EndPredictionBody<'a> {
/// ID of the winning outcome for the Prediction. This parameter is required if status is being set to [`RESOLVED`](types::PredictionStatus).
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub winning_outcome_id: Option<&'a types::PredictionIdRef>,
+ pub winning_outcome_id: Option<Cow<'a, types::PredictionIdRef>>,
}
impl<'a> EndPredictionBody<'a> {
/// End given prediction that is currently active.
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::PredictionIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::PredictionIdRef> + 'a,
status: impl Into<types::PredictionStatus>,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
status: status.into(),
winning_outcome_id: None,
}
@@ -123,9 +123,9 @@ impl<'a> EndPredictionBody<'a> {
/// This parameter is required if status is being set to [`RESOLVED`](types::PredictionStatus).
pub fn winning_outcome_id(
mut self,
- winning_outcome_id: impl Into<&'a types::PredictionIdRef>,
+ winning_outcome_id: impl types::IntoCow<'a, types::PredictionIdRef> + 'a,
) -> Self {
- self.winning_outcome_id = Some(winning_outcome_id.into());
+ self.winning_outcome_id = Some(winning_outcome_id.to_cow());
self
}
}
diff --git a/src/helix/endpoints/predictions/get_predictions.rs b/src/helix/endpoints/predictions/get_predictions.rs
index bc24bbfbc..8d9b15f83 100644
--- a/src/helix/endpoints/predictions/get_predictions.rs
+++ b/src/helix/endpoints/predictions/get_predictions.rs
@@ -39,7 +39,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
pub use types::{PredictionOutcome, PredictionOutcomeId, PredictionStatus};
/// Query Parameters for [Get predictions](super::get_predictions)
@@ -52,7 +51,7 @@ pub struct GetPredictionsRequest<'a> {
/// The broadcaster running Predictions. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// ID of a Prediction. Filters results to one or more specific Predictions.
/// Not providing one or more IDs will return the full list of Predictions for the authenticated channel.
///
@@ -70,9 +69,9 @@ pub struct GetPredictionsRequest<'a> {
impl<'a> GetPredictionsRequest<'a> {
/// Get information about predictions for this broadcasters channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
id: Cow::Borrowed(&[]),
after: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/predictions/mod.rs b/src/helix/endpoints/predictions/mod.rs
index 715a54c54..5b58a8f01 100644
--- a/src/helix/endpoints/predictions/mod.rs
+++ b/src/helix/endpoints/predictions/mod.rs
@@ -5,6 +5,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod create_prediction;
pub mod end_prediction;
diff --git a/src/helix/endpoints/raids/cancel_a_raid.rs b/src/helix/endpoints/raids/cancel_a_raid.rs
index 746451fd5..486b04add 100644
--- a/src/helix/endpoints/raids/cancel_a_raid.rs
+++ b/src/helix/endpoints/raids/cancel_a_raid.rs
@@ -49,14 +49,14 @@ pub struct CancelARaidRequest<'a> {
/// The ID of the broadcaster that sent the raiding party.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> CancelARaidRequest<'a> {
/// Cancel a pending raid on this broadcasters channel
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/raids/mod.rs b/src/helix/endpoints/raids/mod.rs
index b5af0a66b..c211a295c 100644
--- a/src/helix/endpoints/raids/mod.rs
+++ b/src/helix/endpoints/raids/mod.rs
@@ -5,6 +5,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod cancel_a_raid;
pub mod start_a_raid;
diff --git a/src/helix/endpoints/raids/start_a_raid.rs b/src/helix/endpoints/raids/start_a_raid.rs
index 2743794da..a29b91497 100644
--- a/src/helix/endpoints/raids/start_a_raid.rs
+++ b/src/helix/endpoints/raids/start_a_raid.rs
@@ -47,22 +47,22 @@ pub struct StartARaidRequest<'a> {
/// The ID of the broadcaster that’s sending the raiding party.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- from_broadcaster_id: &'a types::UserIdRef,
+ from_broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the broadcaster to raid.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- to_broadcaster_id: &'a types::UserIdRef,
+ to_broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> StartARaidRequest<'a> {
/// Create a new [`StartARaidRequest`]
pub fn new(
- from_broadcaster_id: impl Into<&'a types::UserIdRef>,
- to_broadcaster_id: impl Into<&'a types::UserIdRef>,
+ from_broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ to_broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- from_broadcaster_id: from_broadcaster_id.into(),
- to_broadcaster_id: to_broadcaster_id.into(),
+ from_broadcaster_id: from_broadcaster_id.to_cow(),
+ to_broadcaster_id: to_broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/schedule/create_channel_stream_schedule_segment.rs b/src/helix/endpoints/schedule/create_channel_stream_schedule_segment.rs
index a7de354c4..1014250e4 100644
--- a/src/helix/endpoints/schedule/create_channel_stream_schedule_segment.rs
+++ b/src/helix/endpoints/schedule/create_channel_stream_schedule_segment.rs
@@ -25,7 +25,7 @@
//! # use twitch_api::helix::schedule::create_channel_stream_schedule_segment;
//! let body =
//! create_channel_stream_schedule_segment::CreateChannelStreamScheduleSegmentBody::builder()
-//! .start_time(&*twitch_api::types::Timestamp::try_from("2021-07-01T18:00:00Z").unwrap())
+//! .start_time(&twitch_api::types::Timestamp::try_from("2021-07-01T18:00:00Z").unwrap())
//! .timezone("America/New_York")
//! .is_recurring(false)
//! .duration("60")
@@ -54,7 +54,7 @@
//! .build();
//! let timestamp = twitch_api::types::Timestamp::try_from("2021-07-01T18:00:00Z")?;
//! let body = create_channel_stream_schedule_segment::CreateChannelStreamScheduleSegmentBody::builder()
-//! .start_time(&*timestamp)
+//! .start_time(×tamp)
//! .timezone("America/New_York")
//! .is_recurring(false)
//! .duration("60")
@@ -81,14 +81,14 @@ pub struct CreateChannelStreamScheduleSegmentRequest<'a> {
/// User ID of the broadcaster who owns the channel streaming schedule. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> CreateChannelStreamScheduleSegmentRequest<'a> {
/// Create a single scheduled broadcast or a recurring scheduled broadcast for a channel’s [stream schedule](https://help.twitch.tv/s/article/channel-page-setup#Schedule).
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
@@ -103,7 +103,7 @@ pub struct CreateChannelStreamScheduleSegmentBody<'a> {
/// Start time for the scheduled broadcast specified in RFC3339 format.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub start_time: &'a types::TimestampRef,
+ pub start_time: Cow<'a, types::TimestampRef>,
// FIXME: specific braid?
/// The timezone of the application creating the scheduled broadcast using the IANA time zone database format.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
@@ -118,7 +118,7 @@ pub struct CreateChannelStreamScheduleSegmentBody<'a> {
/// Game/Category ID for the scheduled broadcast.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
- pub category_id: Option<&'a types::CategoryIdRef>,
+ pub category_id: Option<Cow<'a, types::CategoryIdRef>>,
/// Title for the scheduled broadcast. Maximum: 140 characters.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
@@ -128,12 +128,12 @@ pub struct CreateChannelStreamScheduleSegmentBody<'a> {
impl<'a> CreateChannelStreamScheduleSegmentBody<'a> {
/// Create a single scheduled broadcast or a recurring scheduled broadcast for a channel’s [stream schedule](https://help.twitch.tv/s/article/channel-page-setup#Schedule).
pub fn new(
- start_time: impl Into<&'a types::TimestampRef>,
+ start_time: impl types::IntoCow<'a, types::TimestampRef> + 'a,
timezone: impl Into<&'a str>,
is_recurring: bool,
) -> Self {
Self {
- start_time: start_time.into(),
+ start_time: start_time.to_cow(),
timezone: timezone.into(),
is_recurring,
duration: Default::default(),
@@ -173,7 +173,7 @@ fn test_request() {
let ts = types::Timestamp::try_from("2021-07-01T18:00:00Z").unwrap();
let body = CreateChannelStreamScheduleSegmentBody {
duration: Some("60"),
- category_id: Some("509670".into()),
+ category_id: Some(types::IntoCow::to_cow("509670")),
title: Some("TwitchDev Monthly Update // July 1, 2021"),
..CreateChannelStreamScheduleSegmentBody::new(&*ts, "America/New_York", false)
};
diff --git a/src/helix/endpoints/schedule/delete_channel_stream_schedule_segment.rs b/src/helix/endpoints/schedule/delete_channel_stream_schedule_segment.rs
index 1a672786a..33bbca537 100644
--- a/src/helix/endpoints/schedule/delete_channel_stream_schedule_segment.rs
+++ b/src/helix/endpoints/schedule/delete_channel_stream_schedule_segment.rs
@@ -54,22 +54,22 @@ pub struct DeleteChannelStreamScheduleSegmentRequest<'a> {
/// User ID of the broadcaster who owns the channel streaming schedule. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the streaming segment to delete.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::StreamSegmentIdRef,
+ pub id: Cow<'a, types::StreamSegmentIdRef>,
}
impl<'a> DeleteChannelStreamScheduleSegmentRequest<'a> {
/// Delete a single scheduled broadcast or a recurring scheduled broadcast for a channel’s [stream schedule](https://help.twitch.tv/s/article/channel-page-setup#Schedule).
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::StreamSegmentIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::StreamSegmentIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/schedule/get_channel_stream_schedule.rs b/src/helix/endpoints/schedule/get_channel_stream_schedule.rs
index fdf1053e6..2e5a94e67 100644
--- a/src/helix/endpoints/schedule/get_channel_stream_schedule.rs
+++ b/src/helix/endpoints/schedule/get_channel_stream_schedule.rs
@@ -51,15 +51,15 @@ pub struct GetChannelStreamScheduleRequest<'a> {
/// User ID of the broadcaster who owns the channel streaming schedule. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the stream segment to return. Maximum: 100.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub id: Option<&'a types::StreamSegmentIdRef>,
+ pub id: Option<Cow<'a, types::StreamSegmentIdRef>>,
/// A timestamp in RFC3339 format to start returning stream segments from. If not specified, the current date and time is used.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub start_time: Option<&'a types::TimestampRef>,
+ pub start_time: Option<Cow<'a, types::TimestampRef>>,
/// A timezone offset for the requester specified in minutes. This is recommended to ensure stream segments are returned for the correct week. For example, a timezone that is +4 hours from GMT would be “240.” If not specified, “0” is used for GMT.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
@@ -74,9 +74,9 @@ pub struct GetChannelStreamScheduleRequest<'a> {
impl<'a> GetChannelStreamScheduleRequest<'a> {
/// Get a broadcasters schedule
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
id: Default::default(),
start_time: Default::default(),
utc_offset: Default::default(),
@@ -86,14 +86,17 @@ impl<'a> GetChannelStreamScheduleRequest<'a> {
}
/// Set the id for the request.
- pub fn id(mut self, id: impl Into<&'a types::StreamSegmentIdRef>) -> Self {
- self.id = Some(id.into());
+ pub fn id(mut self, id: impl types::IntoCow<'a, types::StreamSegmentIdRef> + 'a) -> Self {
+ self.id = Some(id.to_cow());
self
}
/// Set the start_time for the request.
- pub fn start_time(mut self, start_time: impl Into<&'a types::TimestampRef>) -> Self {
- self.start_time = Some(start_time.into());
+ pub fn start_time(
+ mut self,
+ start_time: impl types::IntoCow<'a, types::TimestampRef> + 'a,
+ ) -> Self {
+ self.start_time = Some(start_time.to_cow());
self
}
diff --git a/src/helix/endpoints/schedule/mod.rs b/src/helix/endpoints/schedule/mod.rs
index 3abf3ebbb..6bceba272 100644
--- a/src/helix/endpoints/schedule/mod.rs
+++ b/src/helix/endpoints/schedule/mod.rs
@@ -4,6 +4,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod create_channel_stream_schedule_segment;
pub mod delete_channel_stream_schedule_segment;
diff --git a/src/helix/endpoints/schedule/update_channel_stream_schedule.rs b/src/helix/endpoints/schedule/update_channel_stream_schedule.rs
index 4fea71883..a62dfaf49 100644
--- a/src/helix/endpoints/schedule/update_channel_stream_schedule.rs
+++ b/src/helix/endpoints/schedule/update_channel_stream_schedule.rs
@@ -53,18 +53,18 @@ pub struct UpdateChannelStreamScheduleRequest<'a> {
/// User ID of the broadcaster who owns the channel streaming schedule. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Indicates if Vacation Mode is enabled. Set to true to add a vacation or false to remove vacation from the channel streaming schedule.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
pub is_vacation_enabled: Option<bool>,
/// Start time for vacation specified in RFC3339 format. Required if is_vacation_enabled is set to true.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub vacation_start_time: Option<&'a types::TimestampRef>,
+ pub vacation_start_time: Option<Cow<'a, types::TimestampRef>>,
/// End time for vacation specified in RFC3339 format. Required if is_vacation_enabled is set to true.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub vacation_end_time: Option<&'a types::TimestampRef>,
+ pub vacation_end_time: Option<Cow<'a, types::TimestampRef>>,
/// The timezone for when the vacation is being scheduled using the IANA time zone database format. Required if is_vacation_enabled is set to true.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
@@ -73,9 +73,9 @@ pub struct UpdateChannelStreamScheduleRequest<'a> {
impl<'a> UpdateChannelStreamScheduleRequest<'a> {
/// Update the settings for a channel’s stream schedule.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
is_vacation_enabled: Default::default(),
vacation_start_time: Default::default(),
vacation_end_time: Default::default(),
@@ -149,8 +149,8 @@ fn test_request() {
let end = types::Timestamp::try_from("2021-05-23T00:00:00Z").unwrap();
let req = UpdateChannelStreamScheduleRequest {
is_vacation_enabled: Some(true),
- vacation_start_time: Some(&start),
- vacation_end_time: Some(&end),
+ vacation_start_time: Some(types::IntoCow::to_cow(&start)),
+ vacation_end_time: Some(types::IntoCow::to_cow(&end)),
timezone: Some("America/New_York"),
..UpdateChannelStreamScheduleRequest::broadcaster_id("141981764")
};
diff --git a/src/helix/endpoints/schedule/update_channel_stream_schedule_segment.rs b/src/helix/endpoints/schedule/update_channel_stream_schedule_segment.rs
index 3b6c33546..d6f6690f3 100644
--- a/src/helix/endpoints/schedule/update_channel_stream_schedule_segment.rs
+++ b/src/helix/endpoints/schedule/update_channel_stream_schedule_segment.rs
@@ -68,22 +68,22 @@ pub struct UpdateChannelStreamScheduleSegmentRequest<'a> {
/// User ID of the broadcaster who owns the channel streaming schedule. Provided broadcaster_id must match the user_id in the user OAuth token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// The ID of the streaming segment to update.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub id: &'a types::StreamSegmentIdRef,
+ pub id: Cow<'a, types::StreamSegmentIdRef>,
}
impl<'a> UpdateChannelStreamScheduleSegmentRequest<'a> {
/// Update a single scheduled broadcast or a recurring scheduled broadcast for a channel’s [stream schedule](https://help.twitch.tv/s/article/channel-page-setup#Schedule).
pub fn new(
- broadcaster_id: impl Into<&'a types::UserIdRef>,
- id: impl Into<&'a types::StreamSegmentIdRef>,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ id: impl types::IntoCow<'a, types::StreamSegmentIdRef> + 'a,
) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
- id: id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
+ id: id.to_cow(),
}
}
}
@@ -106,7 +106,7 @@ pub struct UpdateChannelStreamScheduleSegmentBody<'a> {
/// Game/Category ID for the scheduled broadcast.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
- pub category_id: Option<&'a types::CategoryIdRef>,
+ pub category_id: Option<Cow<'a, types::CategoryIdRef>>,
/// Title for the scheduled broadcast. Maximum: 140 characters.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(skip_serializing_if = "Option::is_none", borrow)]
diff --git a/src/helix/endpoints/search/mod.rs b/src/helix/endpoints/search/mod.rs
index 08bfe5430..79f074bf8 100644
--- a/src/helix/endpoints/search/mod.rs
+++ b/src/helix/endpoints/search/mod.rs
@@ -22,6 +22,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod search_categories;
pub mod search_channels;
diff --git a/src/helix/endpoints/search/search_categories.rs b/src/helix/endpoints/search/search_categories.rs
index 3e1941d8e..3134405f9 100644
--- a/src/helix/endpoints/search/search_categories.rs
+++ b/src/helix/endpoints/search/search_categories.rs
@@ -50,7 +50,7 @@ pub struct SearchCategoriesRequest<'a> {
/// URI encoded search query
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub query: &'a str,
+ pub query: Cow<'a, str>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub after: Option<helix::Cursor>,
@@ -67,7 +67,7 @@ impl<'a> SearchCategoriesRequest<'a> {
/// Search categories with the following query.
pub fn query(query: impl Into<&'a str>) -> Self {
Self {
- query: query.into(),
+ query: query.into().into(),
after: None,
before: None,
first: None,
diff --git a/src/helix/endpoints/streams/get_followed_streams.rs b/src/helix/endpoints/streams/get_followed_streams.rs
index d9f4efc2d..48158e58f 100644
--- a/src/helix/endpoints/streams/get_followed_streams.rs
+++ b/src/helix/endpoints/streams/get_followed_streams.rs
@@ -50,7 +50,7 @@ pub struct GetFollowedStreamsRequest<'a> {
/// Returns streams broadcast by one or more specified user IDs. You can specify up to 100 IDs.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub user_id: &'a types::UserIdRef,
+ pub user_id: Cow<'a, types::UserIdRef>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub after: Option<helix::Cursor>,
@@ -69,9 +69,9 @@ impl<'a> GetFollowedStreamsRequest<'a> {
/// Requires token with scope [`user:read:follows`](twitch_oauth2::Scope::UserReadFollows).
///
/// See also [`HelixClient::get_followed_streams`](crate::helix::HelixClient::get_followed_streams).
- pub fn user_id(user_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn user_id(user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- user_id: user_id.into(),
+ user_id: user_id.to_cow(),
after: Default::default(),
before: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/streams/get_stream_tags.rs b/src/helix/endpoints/streams/get_stream_tags.rs
index f8941a275..044b226c7 100644
--- a/src/helix/endpoints/streams/get_stream_tags.rs
+++ b/src/helix/endpoints/streams/get_stream_tags.rs
@@ -51,14 +51,14 @@ pub struct GetStreamTagsRequest<'a> {
/// ID of the stream whose tags are going to be fetched
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetStreamTagsRequest<'a> {
/// ID of the stream whose tags are going to be fetched
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/streams/get_streams.rs b/src/helix/endpoints/streams/get_streams.rs
index c882a949b..b8a51247f 100644
--- a/src/helix/endpoints/streams/get_streams.rs
+++ b/src/helix/endpoints/streams/get_streams.rs
@@ -41,7 +41,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Streams](super::get_streams)
///
diff --git a/src/helix/endpoints/streams/mod.rs b/src/helix/endpoints/streams/mod.rs
index 919f9e12d..d2061f5ec 100644
--- a/src/helix/endpoints/streams/mod.rs
+++ b/src/helix/endpoints/streams/mod.rs
@@ -24,6 +24,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
#[doc(inline)]
pub use get_followed_streams::GetFollowedStreamsRequest;
diff --git a/src/helix/endpoints/streams/replace_stream_tags.rs b/src/helix/endpoints/streams/replace_stream_tags.rs
index 538acd02c..43783a0da 100644
--- a/src/helix/endpoints/streams/replace_stream_tags.rs
+++ b/src/helix/endpoints/streams/replace_stream_tags.rs
@@ -60,7 +60,6 @@
//! and parse the [`http::Response`] with [`ReplaceStreamTagsRequest::parse_response(None, &request.get_uri(), response)`](ReplaceStreamTagsRequest::parse_response)
use super::*;
use helix::RequestPut;
-use std::borrow::Cow;
/// Query Parameters for [Replace Stream Tags](super::replace_stream_tags)
///
@@ -72,14 +71,14 @@ pub struct ReplaceStreamTagsRequest<'a> {
/// ID of the stream for which tags are to be replaced.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> ReplaceStreamTagsRequest<'a> {
/// ID of the stream for which tags are to be replaced.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/subscriptions/check_user_subscription.rs b/src/helix/endpoints/subscriptions/check_user_subscription.rs
index 8c5fd1637..9f5fd4593 100644
--- a/src/helix/endpoints/subscriptions/check_user_subscription.rs
+++ b/src/helix/endpoints/subscriptions/check_user_subscription.rs
@@ -38,7 +38,6 @@
//! and parse the [`http::Response`] with [`CheckUserSubscriptionRequest::parse_response(None, &request.get_uri(), response)`](CheckUserSubscriptionRequest::parse_response)
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Check User Subscription](super::check_user_subscription)
///
@@ -50,7 +49,7 @@ pub struct CheckUserSubscriptionRequest<'a> {
/// User ID of the broadcaster. Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Unique identifier of account to get subscription status of. Accepts up to 100 values.
#[cfg_attr(feature = "typed-builder", builder(default))]
#[serde(borrow)]
@@ -59,9 +58,9 @@ pub struct CheckUserSubscriptionRequest<'a> {
impl<'a> CheckUserSubscriptionRequest<'a> {
/// Checks subscribed users to this specific channel.
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
}
}
diff --git a/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions.rs b/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions.rs
index 39f26ce21..ce53f3cee 100644
--- a/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions.rs
+++ b/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions.rs
@@ -39,7 +39,7 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
+
/// Query Parameters for [Get Broadcaster Subscriptions](super::get_broadcaster_subscriptions)
///
/// [`get-broadcaster-subscriptions`](https://dev.twitch.tv/docs/api/reference#get-broadcaster-subscriptions)
@@ -50,7 +50,7 @@ pub struct GetBroadcasterSubscriptionsRequest<'a> {
/// User ID of the broadcaster. Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Unique identifier of account to get subscription status of. Accepts up to 100 values.
#[cfg_attr(feature = "typed-builder", builder(default))]
#[serde(borrow)]
@@ -65,9 +65,9 @@ pub struct GetBroadcasterSubscriptionsRequest<'a> {
impl<'a> GetBroadcasterSubscriptionsRequest<'a> {
/// Get a broadcasters subscribers
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
after: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions_events.rs b/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions_events.rs
index 6d843ff1a..8a80212fc 100644
--- a/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions_events.rs
+++ b/src/helix/endpoints/subscriptions/get_broadcaster_subscriptions_events.rs
@@ -46,7 +46,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Broadcaster Subscriptions Events](super::get_broadcaster_subscriptions_events)
///
@@ -58,7 +57,7 @@ pub struct GetBroadcasterSubscriptionsEventsRequest<'a> {
/// Must match the User ID in the Bearer token.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Filters the results and only returns a status object for users who have a subscribe event in this channel and have a matching user_id.
/// Maximum: 100
#[cfg_attr(feature = "typed-builder", builder(default))]
@@ -78,9 +77,9 @@ pub struct GetBroadcasterSubscriptionsEventsRequest<'a> {
impl<'a> GetBroadcasterSubscriptionsEventsRequest<'a> {
/// Get events for this broadcaster
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
user_id: Cow::Borrowed(&[]),
after: Default::default(),
first: Default::default(),
diff --git a/src/helix/endpoints/subscriptions/mod.rs b/src/helix/endpoints/subscriptions/mod.rs
index e1c3a41ab..e401405e7 100644
--- a/src/helix/endpoints/subscriptions/mod.rs
+++ b/src/helix/endpoints/subscriptions/mod.rs
@@ -26,6 +26,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod check_user_subscription;
pub mod get_broadcaster_subscriptions;
diff --git a/src/helix/endpoints/tags/get_all_stream_tags.rs b/src/helix/endpoints/tags/get_all_stream_tags.rs
index 1c53d2d09..aa3f434b7 100644
--- a/src/helix/endpoints/tags/get_all_stream_tags.rs
+++ b/src/helix/endpoints/tags/get_all_stream_tags.rs
@@ -38,7 +38,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get All Stream Tags](super::get_all_stream_tags)
///
diff --git a/src/helix/endpoints/tags/mod.rs b/src/helix/endpoints/tags/mod.rs
index 698d1c979..61a2a8e09 100644
--- a/src/helix/endpoints/tags/mod.rs
+++ b/src/helix/endpoints/tags/mod.rs
@@ -22,6 +22,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
use std::collections::HashMap;
pub mod get_all_stream_tags;
diff --git a/src/helix/endpoints/teams/get_channel_teams.rs b/src/helix/endpoints/teams/get_channel_teams.rs
index 94cc1ead0..6c956ea3b 100644
--- a/src/helix/endpoints/teams/get_channel_teams.rs
+++ b/src/helix/endpoints/teams/get_channel_teams.rs
@@ -48,14 +48,14 @@ pub struct GetChannelTeamsRequest<'a> {
/// Team ID.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
}
impl<'a> GetChannelTeamsRequest<'a> {
/// Get the team of this specific broadcaster
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/teams/get_teams.rs b/src/helix/endpoints/teams/get_teams.rs
index 0a00c006c..6b9f0018d 100644
--- a/src/helix/endpoints/teams/get_teams.rs
+++ b/src/helix/endpoints/teams/get_teams.rs
@@ -48,7 +48,7 @@ pub struct GetTeamsRequest<'a> {
/// Team ID.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub id: Option<&'a types::TeamIdRef>,
+ pub id: Option<Cow<'a, types::TeamIdRef>>,
/// Team name.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
@@ -57,9 +57,9 @@ pub struct GetTeamsRequest<'a> {
impl<'a> GetTeamsRequest<'a> {
/// Get team with this [`TeamId`](types::TeamId)
- pub fn id(id: impl Into<&'a types::TeamIdRef>) -> Self {
+ pub fn id(id: impl types::IntoCow<'a, types::TeamIdRef> + 'a) -> Self {
Self {
- id: Some(id.into()),
+ id: Some(id.to_cow()),
name: None,
}
}
diff --git a/src/helix/endpoints/teams/mod.rs b/src/helix/endpoints/teams/mod.rs
index 6b949b4e9..ba9ed304f 100644
--- a/src/helix/endpoints/teams/mod.rs
+++ b/src/helix/endpoints/teams/mod.rs
@@ -5,6 +5,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod get_channel_teams;
pub mod get_teams;
diff --git a/src/helix/endpoints/users/block_user.rs b/src/helix/endpoints/users/block_user.rs
index 88de0bb3c..933bfadd4 100644
--- a/src/helix/endpoints/users/block_user.rs
+++ b/src/helix/endpoints/users/block_user.rs
@@ -56,7 +56,7 @@ pub struct BlockUserRequest<'a> {
/// User ID of the follower
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub target_user_id: &'a types::UserIdRef,
+ pub target_user_id: Cow<'a, types::UserIdRef>,
/// Source context for blocking the user. Valid values: "chat", "whisper".
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
pub source_context: Option<SourceContext>,
@@ -67,9 +67,9 @@ pub struct BlockUserRequest<'a> {
impl<'a> BlockUserRequest<'a> {
/// Block a user
- pub fn block_user(target_user_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn block_user(target_user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- target_user_id: target_user_id.into(),
+ target_user_id: target_user_id.to_cow(),
source_context: None,
reason: None,
}
diff --git a/src/helix/endpoints/users/get_user_block_list.rs b/src/helix/endpoints/users/get_user_block_list.rs
index 4cac7f2c2..2dfeddc8c 100644
--- a/src/helix/endpoints/users/get_user_block_list.rs
+++ b/src/helix/endpoints/users/get_user_block_list.rs
@@ -48,7 +48,7 @@ pub struct GetUserBlockListRequest<'a> {
/// User ID for a Twitch user.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub broadcaster_id: &'a types::UserIdRef,
+ pub broadcaster_id: Cow<'a, types::UserIdRef>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub after: Option<helix::Cursor>,
@@ -59,9 +59,9 @@ pub struct GetUserBlockListRequest<'a> {
impl<'a> GetUserBlockListRequest<'a> {
/// Get a specified user’s block list
- pub fn broadcaster_id(broadcaster_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn broadcaster_id(broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- broadcaster_id: broadcaster_id.into(),
+ broadcaster_id: broadcaster_id.to_cow(),
after: Default::default(),
first: Default::default(),
}
diff --git a/src/helix/endpoints/users/get_users.rs b/src/helix/endpoints/users/get_users.rs
index 153115e5d..e85ed4a14 100644
--- a/src/helix/endpoints/users/get_users.rs
+++ b/src/helix/endpoints/users/get_users.rs
@@ -41,7 +41,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
/// Query Parameters for [Get Users](super::get_users)
///
diff --git a/src/helix/endpoints/users/get_users_follows.rs b/src/helix/endpoints/users/get_users_follows.rs
index 994541578..048a9b362 100644
--- a/src/helix/endpoints/users/get_users_follows.rs
+++ b/src/helix/endpoints/users/get_users_follows.rs
@@ -53,38 +53,38 @@ pub struct GetUsersFollowsRequest<'a> {
/// User ID. The request returns information about users who are being followed by the from_id user.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub from_id: Option<&'a types::UserIdRef>,
+ pub from_id: Option<Cow<'a, types::UserIdRef>>,
/// User ID. The request returns information about users who are following the to_id user.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub to_id: Option<&'a types::UserIdRef>,
+ pub to_id: Option<Cow<'a, types::UserIdRef>>,
}
impl<'a> GetUsersFollowsRequest<'a> {
/// Get the broadcasters that `from_id` is following
- pub fn following(from_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn following(from_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- from_id: Some(from_id.into()),
+ from_id: Some(from_id.to_cow()),
..Self::empty()
}
}
/// Get the followers of `to_id`
- pub fn followers(to_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn followers(to_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- to_id: Some(to_id.into()),
+ to_id: Some(to_id.to_cow()),
..Self::empty()
}
}
/// Check if user follows a specific broadcaster
pub fn follows(
- user_id: impl Into<&'a types::UserIdRef>,
- broadcaster_id: impl Into<&'a types::UserIdRef>,
+ user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ broadcaster_id: impl types::IntoCow<'a, types::UserIdRef> + 'a,
) -> Self {
Self {
- from_id: Some(user_id.into()),
- to_id: Some(broadcaster_id.into()),
+ from_id: Some(user_id.to_cow()),
+ to_id: Some(broadcaster_id.to_cow()),
..Self::empty()
}
}
diff --git a/src/helix/endpoints/users/mod.rs b/src/helix/endpoints/users/mod.rs
index 76539ac4b..9007f03d0 100644
--- a/src/helix/endpoints/users/mod.rs
+++ b/src/helix/endpoints/users/mod.rs
@@ -24,6 +24,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod block_user;
pub mod get_user_block_list;
diff --git a/src/helix/endpoints/users/unblock_user.rs b/src/helix/endpoints/users/unblock_user.rs
index bb806fd10..34894ee95 100644
--- a/src/helix/endpoints/users/unblock_user.rs
+++ b/src/helix/endpoints/users/unblock_user.rs
@@ -49,14 +49,14 @@ pub struct UnblockUserRequest<'a> {
/// User ID of the follower
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub target_user_id: &'a types::UserIdRef,
+ pub target_user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> UnblockUserRequest<'a> {
/// Create a new unblock request
- pub fn unblock_user(target_user_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn unblock_user(target_user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- target_user_id: target_user_id.into(),
+ target_user_id: target_user_id.to_cow(),
}
}
}
diff --git a/src/helix/endpoints/videos/delete_videos.rs b/src/helix/endpoints/videos/delete_videos.rs
index e0c073602..0a2abcbab 100644
--- a/src/helix/endpoints/videos/delete_videos.rs
+++ b/src/helix/endpoints/videos/delete_videos.rs
@@ -40,7 +40,6 @@
use super::*;
use helix::RequestDelete;
-use std::borrow::Cow;
// FIXME: One of id, user_id or game_id needs to be specified. typed_builder should have enums. id can not be used with other params
/// Query Parameters for [Delete Videos](super::delete_videos)
diff --git a/src/helix/endpoints/videos/get_videos.rs b/src/helix/endpoints/videos/get_videos.rs
index 5481df4cb..6f1b76c8c 100644
--- a/src/helix/endpoints/videos/get_videos.rs
+++ b/src/helix/endpoints/videos/get_videos.rs
@@ -39,7 +39,6 @@
use super::*;
use helix::RequestGet;
-use std::borrow::Cow;
// FIXME: One of id, user_id or game_id needs to be specified. typed_builder should have enums. id can not be used with other params
/// Query Parameters for [Get Videos](super::get_videos)
@@ -59,11 +58,11 @@ pub struct GetVideosRequest<'a> {
/// ID of the user who owns the video.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub user_id: Option<&'a types::UserIdRef>,
+ pub user_id: Option<Cow<'a, types::UserIdRef>>,
/// ID of the game the video is of.
#[cfg_attr(feature = "typed-builder", builder(default, setter(into)))]
#[serde(borrow)]
- pub game_id: Option<&'a types::CategoryIdRef>,
+ pub game_id: Option<Cow<'a, types::CategoryIdRef>>,
/// Cursor for forward pagination: tells the server where to start fetching the next set of results, in a multi-page response. The cursor value specified here is from the pagination response field of a prior query.
#[cfg_attr(feature = "typed-builder", builder(default))]
pub after: Option<helix::Cursor>,
@@ -100,17 +99,17 @@ impl<'a> GetVideosRequest<'a> {
}
/// ID of the user who owns the video.
- pub fn user_id(user_id: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn user_id(user_id: impl types::IntoCow<'a, types::UserIdRef> + 'a) -> Self {
Self {
- user_id: Some(user_id.into()),
+ user_id: Some(user_id.to_cow()),
..Self::default()
}
}
/// ID of the game the video is of.
- pub fn game_id(game_id: impl Into<&'a types::CategoryIdRef>) -> Self {
+ pub fn game_id(game_id: impl types::IntoCow<'a, types::CategoryIdRef> + 'a) -> Self {
Self {
- game_id: Some(game_id.into()),
+ game_id: Some(game_id.to_cow()),
..Self::default()
}
}
diff --git a/src/helix/endpoints/videos/mod.rs b/src/helix/endpoints/videos/mod.rs
index f4dcf326a..cca77322c 100644
--- a/src/helix/endpoints/videos/mod.rs
+++ b/src/helix/endpoints/videos/mod.rs
@@ -23,6 +23,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod delete_videos;
pub mod get_videos;
diff --git a/src/helix/endpoints/whispers/mod.rs b/src/helix/endpoints/whispers/mod.rs
index 6420e8285..fc2d53d1c 100644
--- a/src/helix/endpoints/whispers/mod.rs
+++ b/src/helix/endpoints/whispers/mod.rs
@@ -6,6 +6,7 @@ use crate::{
types,
};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
pub mod send_whisper;
diff --git a/src/helix/endpoints/whispers/send_whisper.rs b/src/helix/endpoints/whispers/send_whisper.rs
index 6c256b0b2..3ebfe9e5b 100644
--- a/src/helix/endpoints/whispers/send_whisper.rs
+++ b/src/helix/endpoints/whispers/send_whisper.rs
@@ -63,19 +63,22 @@ pub struct SendWhisperRequest<'a> {
/// The ID of the user sending the whisper. This user must have a verified phone number.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub from_user_id: &'a types::UserIdRef,
+ pub from_user_id: Cow<'a, types::UserIdRef>,
/// The ID of the user to receive the whisper.
#[cfg_attr(feature = "typed-builder", builder(setter(into)))]
#[serde(borrow)]
- pub to_user_id: &'a types::UserIdRef,
+ pub to_user_id: Cow<'a, types::UserIdRef>,
}
impl<'a> SendWhisperRequest<'a> {
/// Create a new [`SendWhisperRequest`]
- pub fn new(from: impl Into<&'a types::UserIdRef>, to: impl Into<&'a types::UserIdRef>) -> Self {
+ pub fn new(
+ from: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ to: impl types::IntoCow<'a, types::UserIdRef> + 'a,
+ ) -> Self {
Self {
- from_user_id: from.into(),
- to_user_id: to.into(),
+ from_user_id: from.to_cow(),
+ to_user_id: to.to_cow(),
}
}
}
diff --git a/twitch_types b/twitch_types
index 4d303a84a..547c624ec 160000
--- a/twitch_types
+++ b/twitch_types
@@ -1 +1 @@
-Subproject commit 4d303a84a748abea87c08b1f2670412f44d01e00
+Subproject commit 547c624ec3f9d9ce0cb20a7f8c61fb0706d50485 |
Done. Btw I wouldn't mind if you committed these changes on my branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nerixyz what do you think about my other changes. Does this work for you?
/// Filter response with this ID | ||
pub fn user_id(self, user_id: impl Into<types::UserId>) -> Self { | ||
Self { | ||
user_id: vec![user_id.into()], | ||
..self | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing this and others is a bit sad, but there is no good way to keep it.
If we could store a impl IntoIter<Item=impl Into<Cow<'_, Ref>>
wherever we have multiples and have serde properly serialize (and deserialize I guess), that'd be nice.
Works for me 👍 Thanks for making these changes! |
9a2c5e8
to
b3c979c
Compare
b3c979c
to
c71717f
Compare
lets do it! bors r+ |
Since #194 only implemented a few references and a lot of changes happened in the meantime, I went ahead and tried to refactor (most) request fields to use references. "most" in this case means that (1)
after
/cursor
s remain owned (since I couldn't get pagination to work) and (2) eventsub requests remain owned.I think having (mostly) non-owned requests is already a big step.
&str
or&types::TypeRef
but should beCow<'_, str>
for theDeserialize
impl (since they might be encoded as escaped characters in JSON). These are mainly user-inputs. user-ids, user-logins, UUIDs and similar can remain, since they aren't escaped in JSON. I think it's fair to make sureDeserialize
works for JSON, but it shouldn't need to work for all encodings.Cow<'_, [&types::TypeRef]>
makes passing (static) slices a bit ugly, because&["foo"]
is&[&str; 1]
and&["foo"][..]
is&[&str]
andCow
'sInto
only accepts the latter.