From a80aa458bfc0cfa083a05f6c8483ade129305e45 Mon Sep 17 00:00:00 2001 From: ByteOtter Date: Fri, 19 Jan 2024 15:14:44 +0100 Subject: [PATCH] swap singleton to regular struct --- src/templates/path.template | 4 +--- src/templates/usings.template | 2 +- src/templates/util.rs.template | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/templates/path.template b/src/templates/path.template index f110ffc..7dbbafb 100644 --- a/src/templates/path.template +++ b/src/templates/path.template @@ -1,7 +1,5 @@ {} {} -pub fn {}(query: {}{}) -> Result {{ - let binding = THANIX_CLIENT.lock().unwrap(); - let state = binding.as_ref().unwrap(); +pub fn {}(state: &ThanixClient, query: {}{}) -> Result {{ return state.client.{}(format!("{{}}{}?{{}}", state.base_url, serde_qs::to_string(&query).unwrap())).header("Authorization", format!("Token {{}}", state.authentication_token)).send(); }} diff --git a/src/templates/usings.template b/src/templates/usings.template index 2205e93..5fc0783 100644 --- a/src/templates/usings.template +++ b/src/templates/usings.template @@ -1,3 +1,3 @@ use serde_qs; use reqwest::Url; -use crate::util::THANIX_CLIENT; +use crate::util::ThanixClient; diff --git a/src/templates/util.rs.template b/src/templates/util.rs.template index a5db8f3..36d3975 100644 --- a/src/templates/util.rs.template +++ b/src/templates/util.rs.template @@ -1,9 +1,6 @@ -use std::sync::Mutex; - pub struct ThanixClient { pub client: reqwest::blocking::Client, pub base_url: String, pub authentication_token: String, } -pub static THANIX_CLIENT: Mutex> = Mutex::new(None);