From 98f140afff7b96b67a776653f236cceba966c3d6 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani Date: Sat, 2 Sep 2023 21:22:29 -0400 Subject: [PATCH] Remove generic variable type from QueryUnwrap trait --- cli/src/queries.rs | 9 ++------- cli/src/queries/player_info.rs | 5 ----- cli/src/queries/search_games.rs | 5 ----- cli/src/queries/tournament_sets.rs | 5 ----- 4 files changed, 2 insertions(+), 22 deletions(-) diff --git a/cli/src/queries.rs b/cli/src/queries.rs index edea877..2320b54 100644 --- a/cli/src/queries.rs +++ b/cli/src/queries.rs @@ -59,18 +59,13 @@ pub struct Timestamp(pub u64); // Query machinery pub trait QueryUnwrap: 'static + QueryBuilder { - type VarsUnwrapped; type Unwrapped; - fn wrap_vars(vars: Self::VarsUnwrapped) -> Vars; fn unwrap_response(response: GraphQlResponse) -> Option; } // Generic function for running start.gg queries -pub fn run_query( - vars: Builder::VarsUnwrapped, - auth: &str, -) -> Option +pub fn run_query(vars: Vars, auth: &str) -> Option where Builder: QueryUnwrap, Vars: Serialize, @@ -78,7 +73,7 @@ where { use cynic::http::ReqwestBlockingExt; - let query = Builder::build(Builder::wrap_vars(vars)); + let query = Builder::build(vars); let response = reqwest::blocking::Client::new() .post("https://api.start.gg/gql/alpha") diff --git a/cli/src/queries/player_info.rs b/cli/src/queries/player_info.rs index debe942..230351c 100644 --- a/cli/src/queries/player_info.rs +++ b/cli/src/queries/player_info.rs @@ -32,13 +32,8 @@ pub struct PlayerInfoResponse { } impl QueryUnwrap for PlayerInfo { - type VarsUnwrapped = PlayerInfoVars; type Unwrapped = PlayerInfoResponse; - fn wrap_vars(vars: PlayerInfoVars) -> PlayerInfoVars { - vars - } - fn unwrap_response(response: GraphQlResponse) -> Option { let player = response.data?.player?; Some(PlayerInfoResponse { diff --git a/cli/src/queries/search_games.rs b/cli/src/queries/search_games.rs index 8658aaf..7de64d7 100644 --- a/cli/src/queries/search_games.rs +++ b/cli/src/queries/search_games.rs @@ -38,13 +38,8 @@ pub struct VideogameResponse { } impl<'a> QueryUnwrap> for VideogameSearch { - type VarsUnwrapped = VideogameSearchVars<'a>; type Unwrapped = Vec; - fn wrap_vars(vars: VideogameSearchVars) -> VideogameSearchVars { - vars - } - fn unwrap_response( response: GraphQlResponse, ) -> Option> { diff --git a/cli/src/queries/tournament_sets.rs b/cli/src/queries/tournament_sets.rs index 4f1d468..74da022 100644 --- a/cli/src/queries/tournament_sets.rs +++ b/cli/src/queries/tournament_sets.rs @@ -106,13 +106,8 @@ pub struct SetResponse { } impl<'a> QueryUnwrap> for TournamentSets { - type VarsUnwrapped = TournamentSetsVars<'a>; type Unwrapped = Vec; - fn wrap_vars(vars: TournamentSetsVars) -> TournamentSetsVars { - vars - } - // This might be the most spaghetti code I've ever written fn unwrap_response( response: GraphQlResponse,