Skip to content

Commit

Permalink
nope
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilgardis committed Dec 14, 2022
1 parent 3c5ce8b commit 644af39
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ futures = { version = "0.3.25", optional = true }
hyper = { version = "0.14.23", optional = true }
twitch_types = { version = "0.3.10", path = "./twitch_types" }
yoke = { version = "0.6.1", features = ["serde", "derive"] }
zerofrom = { version = "0.1.1", features = ["derive"] }

[features]
default = ["deser_borrow"]
Expand Down
12 changes: 6 additions & 6 deletions src/helix/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,17 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
/// # }
/// # // fn main() {run()}
/// ```
pub async fn req_get<R, D, D2, T>(
pub async fn req_get<'d, R, D, T>(
&'a self,
request: R,
token: &T,
) -> Result<
Response<R, yoke::Yoke<D, std::rc::Rc<[u8]>>>,
Response<R, yoke::Yoke<<R as Request>::ResponseOwned, std::rc::Rc<[u8]>>>,
ClientRequestError<<C as crate::HttpClient<'a>>::Error>,
>
where
for<'r> R: RequestGet<Response<'r> = D2> + Request<Response<'r> = D2>,
for<'d> D: yoke::Yokeable<'d, Output = D2> + 'static,
R: RequestGet<Response<'d> = D> + Request<Response<'d> = D>,
<R as Request>::ResponseOwned: for<'y> yoke::Yokeable<'y, Output = D>,
T: TwitchToken + ?Sized,
C: Send,
{
Expand All @@ -142,9 +142,9 @@ impl<'a, C: crate::HttpClient<'a>> HelixClient<'a, C> {
let mut request_opt = None;
let mut total = None;
let mut other = None;
let resp: yoke::Yoke<D, _> = yoke::Yoke::try_attach_to_cart(
let resp: yoke::Yoke<_, _> = yoke::Yoke::try_attach_to_cart(
body,
|body| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
|body: &[u8]| -> Result<_, ClientRequestError<<C as crate::HttpClient<'a>>::Error>> {
let response = http::Response::from_parts(parts, body);
let Response {
data,
Expand Down
5 changes: 4 additions & 1 deletion src/helix/endpoints/users/get_users.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,12 @@ impl<'a> GetUsersRequest<'a> {
/// Return Values for [Get Users](super::get_users)
///
/// [`get-users`](https://dev.twitch.tv/docs/api/reference#get-users)
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable)]
#[derive(PartialEq, Deserialize, Serialize, Debug, Clone, yoke::Yokeable, zerofrom::ZeroFrom)]
#[cfg_attr(feature = "deny_unknown_fields", serde(deny_unknown_fields))]
#[non_exhaustive]
pub struct User<'a> {
/// User’s broadcaster type: "partner", "affiliate", or "".
#[zerofrom(clone)]
pub broadcaster_type: Option<types::BroadcasterType>,
/// Date when the user was created.
pub created_at: Cow<'a, types::TimestampRef>,
Expand All @@ -131,6 +132,7 @@ pub struct User<'a> {
pub profile_image_url: Option<Cow<'a, str>>,
/// User’s type: "staff", "admin", "global_mod", or "".
#[serde(rename = "type")]
#[zerofrom(clone)]
pub type_: Option<types::UserType>,
#[deprecated(
since = "0.7.0",
Expand All @@ -143,6 +145,7 @@ pub struct User<'a> {

impl Request for GetUsersRequest<'_> {
type Response<'a> = Vec<User<'a>>;
type ResponseOwned = Vec<User<'static>>;

#[cfg(feature = "twitch_oauth2")]
const OPT_SCOPE: &'static [twitch_oauth2::Scope] = &[twitch_oauth2::Scope::UserReadEmail];
Expand Down
2 changes: 2 additions & 0 deletions src/helix/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ pub trait Request: serde::Serialize {
const OPT_SCOPE: &'static [twitch_oauth2::Scope] = &[];
/// Response type. twitch's response will deserialize to this.
type Response<'a>: for<'de> serde::de::Deserialize<'de> + PartialEq;
/// Owned response
type ResponseOwned;
/// Defines layout of the url parameters.
fn query(&self) -> Result<String, errors::SerializeError> { ser::to_string(self) }
/// Returns full URI for the request, including query parameters.
Expand Down

0 comments on commit 644af39

Please sign in to comment.