Skip to content

Commit 04c35a0

Browse files
committed
this should be the most correct version
but it doesn't work
1 parent 2d7312c commit 04c35a0

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/helix/client.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,17 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
101101
/// # }
102102
/// # // fn main() {run()}
103103
/// ```
104-
pub async fn req_get<'t, R, D, T>(
104+
pub async fn req_get<R, D, D2, T>(
105105
&'a self,
106106
request: R,
107-
token: &'t T,
107+
token: &T,
108108
) -> Result<
109109
Response<R, yoke::Yoke<D, std::rc::Rc<[u8]>>>,
110110
ClientRequestError<<C as crate::HttpClient<'a>>::Error>,
111111
>
112112
where
113-
for<'r> R: Request + RequestGet<Response<'r> = D> + Request<Response<'r> = D>,
114-
for<'b> yoke::trait_hack::YokeTraitHack<<D as yoke::Yokeable<'b>>::Output>:
115-
serde::de::Deserialize<'b>,
116-
for<'b> D: PartialEq + yoke::Yokeable<'b, Output = D>,
113+
for<'r> R: RequestGet<Response<'r> = D2> + Request<Response<'r> = D2>,
114+
for<'d> D: yoke::Yokeable<'d, Output = D2> + 'static,
117115
T: TwitchToken + ?Sized,
118116
C: Send,
119117
{
@@ -136,7 +134,7 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
136134
body,
137135
|body| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
138136
let response = http::Response::from_parts(parts, body);
139-
let Response::<_, <R as Request>::Response<'_>> {
137+
let Response {
140138
data,
141139
pagination: pagination_inner,
142140
request: request_inner,

src/helix/request.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub trait Request: serde::Serialize {
1818
#[cfg(feature = "twitch_oauth2")]
1919
const OPT_SCOPE: &'static [twitch_oauth2::Scope] = &[];
2020
/// Response type. twitch's response will deserialize to this.
21-
type Response<'a>: for<'de> serde::de::Deserialize<'de> + PartialEq + 'a;
21+
type Response<'a>: for<'de> serde::de::Deserialize<'de> + PartialEq;
2222
/// Defines layout of the url parameters.
2323
fn query(&self) -> Result<String, errors::SerializeError> { ser::to_string(&self) }
2424
/// Returns full URI for the request, including query parameters.
@@ -390,11 +390,11 @@ pub trait RequestGet: Request {
390390
/// # Notes
391391
///
392392
/// Pass in the request to enable [pagination](Response::get_next) if supported.
393-
fn parse_response<'a, 'b>(
394-
request: Option<Self>,
393+
fn parse_response<'a, 'b, S: Request>(
394+
request: Option<S>,
395395
uri: &http::Uri,
396396
response: &'b http::Response<&'a [u8]>,
397-
) -> Result<Response<Self, <Self as Request>::Response<'a>>, HelixRequestGetError>
397+
) -> Result<Response<S, <Self as Request>::Response<'a>>, HelixRequestGetError>
398398
where
399399
Self: Sized,
400400
{
@@ -419,12 +419,12 @@ pub trait RequestGet: Request {
419419
}
420420

421421
/// Parse a response string into the response.
422-
fn parse_inner_response<'a>(
423-
request: Option<Self>,
422+
fn parse_inner_response<'a, S: Request>(
423+
request: Option<S>,
424424
uri: &http::Uri,
425425
response: &'a str,
426426
status: http::StatusCode,
427-
) -> Result<Response<Self, <Self as Request>::Response<'a>>, HelixRequestGetError>
427+
) -> Result<Response<S, <Self as Request>::Response<'a>>, HelixRequestGetError>
428428
where
429429
Self: Sized,
430430
{

0 commit comments

Comments
 (0)