Skip to content

Commit 644af39

Browse files
committed
nope
1 parent 3c5ce8b commit 644af39

File tree

5 files changed

+14
-7
lines changed

5 files changed

+14
-7
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ futures = { version = "0.3.25", optional = true }
5959
hyper = { version = "0.14.23", optional = true }
6060
twitch_types = { version = "0.3.10", path = "./twitch_types" }
6161
yoke = { version = "0.6.1", features = ["serde", "derive"] }
62+
zerofrom = { version = "0.1.1", features = ["derive"] }
6263

6364
[features]
6465
default = ["deser_borrow"]

src/helix/client.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
113113
/// # }
114114
/// # // fn main() {run()}
115115
/// ```
116-
pub async fn req_get<R, D, D2, T>(
116+
pub async fn req_get<'d, R, D, T>(
117117
&'a self,
118118
request: R,
119119
token: &T,
120120
) -> Result<
121-
Response<R, yoke::Yoke<D, std::rc::Rc<[u8]>>>,
121+
Response<R, yoke::Yoke<<R as Request>::ResponseOwned, std::rc::Rc<[u8]>>>,
122122
ClientRequestError<<C as crate::HttpClient<'a>>::Error>,
123123
>
124124
where
125-
for<'r> R: RequestGet<Response<'r> = D2> + Request<Response<'r> = D2>,
126-
for<'d> D: yoke::Yokeable<'d, Output = D2> + 'static,
125+
R: RequestGet<Response<'d> = D> + Request<Response<'d> = D>,
126+
<R as Request>::ResponseOwned: for<'y> yoke::Yokeable<'y, Output = D>,
127127
T: TwitchToken + ?Sized,
128128
C: Send,
129129
{
@@ -142,9 +142,9 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
142142
let mut request_opt = None;
143143
let mut total = None;
144144
let mut other = None;
145-
let resp: yoke::Yoke<D, _> = yoke::Yoke::try_attach_to_cart(
145+
let resp: yoke::Yoke<_, _> = yoke::Yoke::try_attach_to_cart(
146146
body,
147-
|body| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
147+
|body: &[u8]| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
148148
let response = http::Response::from_parts(parts, body);
149149
let Response {
150150
data,

src/helix/endpoints/users/get_users.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,12 @@ impl<'a> GetUsersRequest<'a> {
107107
/// Return Values for [Get Users](super::get_users)
108108
///
109109
/// [`get-users`](https://dev.twitch.tv/docs/api/reference#get-users)
110-
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable)]
110+
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable, zerofrom::ZeroFrom)]
111111
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
112112
#[non_exhaustive]
113113
pub struct User<'a> {
114114
/// User’s broadcaster type: "partner", "affiliate", or "".
115+
#[zerofrom(clone)]
115116
pub broadcaster_type: Option<types::BroadcasterType>,
116117
/// Date when the user was created.
117118
pub created_at: Cow<'a, types::TimestampRef>,
@@ -131,6 +132,7 @@ pub struct User<'a> {
131132
pub profile_image_url: Option<Cow<'a, str>>,
132133
/// User’s type: "staff", "admin", "global_mod", or "".
133134
#[serde(rename = "type")]
135+
#[zerofrom(clone)]
134136
pub type_: Option<types::UserType>,
135137
#[deprecated(
136138
since = "0.7.0",
@@ -143,6 +145,7 @@ pub struct User<'a> {
143145

144146
impl Request for GetUsersRequest<'_> {
145147
type Response<'a> = Vec<User<'a>>;
148+
type ResponseOwned = Vec<User<'static>>;
146149

147150
#[cfg(feature = "twitch_oauth2")]
148151
const OPT_SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::UserReadEmail];

src/helix/request.rs

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ pub trait Request: serde::Serialize {
1919
const OPT_SCOPE: &'static [twitch_oauth2::Scope] = &[];
2020
/// Response type. twitch's response will deserialize to this.
2121
type Response<'a>: for<'de> serde::de::Deserialize<'de> + PartialEq;
22+
/// Owned response
23+
type ResponseOwned;
2224
/// Defines layout of the url parameters.
2325
fn query(&self) -> Result<String, errors::SerializeError> { ser::to_string(self) }
2426
/// Returns full URI for the request, including query parameters.

0 commit comments

Comments
 (0)