Skip to content

Commit 6bb02b1

Browse files
committed
nope
1 parent 04c35a0 commit 6bb02b1

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
@@ -51,6 +51,7 @@ futures = { version = "0.3.16", optional = true }
5151
hyper = { version = "0.14.18", optional = true }
5252
twitch_types = { version = "0.2.0", path = "./twitch_types" }
5353
yoke = { version = "0.6.1", features = ["serde", "derive"] }
54+
zerofrom = { version = "0.1.1", features = ["derive"] }
5455

5556
[features]
5657
default = []

src/helix/client.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,17 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
101101
/// # }
102102
/// # // fn main() {run()}
103103
/// ```
104-
pub async fn req_get<R, D, D2, T>(
104+
pub async fn req_get<'d, R, D, T>(
105105
&'a self,
106106
request: R,
107107
token: &T,
108108
) -> Result<
109-
Response<R, yoke::Yoke<D, std::rc::Rc<[u8]>>>,
109+
Response<R, yoke::Yoke<<R as Request>::ResponseOwned, std::rc::Rc<[u8]>>>,
110110
ClientRequestError<<C as crate::HttpClient<'a>>::Error>,
111111
>
112112
where
113-
for<'r> R: RequestGet<Response<'r> = D2> + Request<Response<'r> = D2>,
114-
for<'d> D: yoke::Yokeable<'d, Output = D2> + 'static,
113+
R: RequestGet<Response<'d> = D> + Request<Response<'d> = D>,
114+
<R as Request>::ResponseOwned: for<'y> yoke::Yokeable<'y, Output = D>,
115115
T: TwitchToken + ?Sized,
116116
C: Send,
117117
{
@@ -130,9 +130,9 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
130130
let mut request_opt = None;
131131
let mut total = None;
132132
let mut other = None;
133-
let resp: yoke::Yoke<D, _> = yoke::Yoke::try_attach_to_cart(
133+
let resp: yoke::Yoke<_, _> = yoke::Yoke::try_attach_to_cart(
134134
body,
135-
|body| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
135+
|body: &[u8]| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
136136
let response = http::Response::from_parts(parts, body);
137137
let Response {
138138
data,

src/helix/endpoints/users/get_users.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ pub struct GetUsersRequest {
5959
/// Return Values for [Get Users](super::get_users)
6060
///
6161
/// [`get-users`](https://dev.twitch.tv/docs/api/reference#get-users)
62-
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable)]
62+
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable, zerofrom::ZeroFrom)]
6363
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
6464
#[non_exhaustive]
6565
pub struct User<'a> {
6666
/// User’s broadcaster type: "partner", "affiliate", or "".
67+
#[zerofrom(clone)]
6768
pub broadcaster_type: Option<types::BroadcasterType>,
6869
/// Date when the user was created.
6970
pub created_at: Cow<'a, types::TimestampRef>,
@@ -83,6 +84,7 @@ pub struct User<'a> {
8384
pub profile_image_url: Option<Cow<'a, str>>,
8485
/// User’s type: "staff", "admin", "global_mod", or "".
8586
#[serde(rename = "type")]
87+
#[zerofrom(clone)]
8688
pub type_: Option<types::UserType>,
8789
#[deprecated(
8890
since = "0.7.0",
@@ -95,6 +97,7 @@ pub struct User<'a> {
9597

9698
impl Request for GetUsersRequest {
9799
type Response<'a> = Vec<User<'a>>;
100+
type ResponseOwned = Vec<User<'static>>;
98101

99102
#[cfg(feature = "twitch_oauth2")]
100103
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)