From 0fa75148c002e933d2efe9ca269d5119be086ff2 Mon Sep 17 00:00:00 2001 From: Jonathan Alter Date: Thu, 23 Oct 2025 00:58:01 -0500 Subject: [PATCH] Revert "use async closure" This reverts commit eee955e3ffb9514d80ed801307f0027fa540e002. --- async-openai-wasm/src/client.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/async-openai-wasm/src/client.rs b/async-openai-wasm/src/client.rs index 570e67f2..932ec1e6 100644 --- a/async-openai-wasm/src/client.rs +++ b/async-openai-wasm/src/client.rs @@ -171,7 +171,7 @@ impl Client { where O: DeserializeOwned, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .get(self.config.url(path)) @@ -189,7 +189,7 @@ impl Client { O: DeserializeOwned, Q: Serialize + ?Sized, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .get(self.config.url(path)) @@ -207,7 +207,7 @@ impl Client { where O: DeserializeOwned, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .delete(self.config.url(path)) @@ -221,7 +221,7 @@ impl Client { /// Make a GET request to {path} and return the response body pub(crate) async fn get_raw(&self, path: &str) -> Result { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .get(self.config.url(path)) @@ -238,7 +238,7 @@ impl Client { where I: Serialize, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .post(self.config.url(path)) @@ -257,7 +257,7 @@ impl Client { I: Serialize, O: DeserializeOwned, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .post(self.config.url(path)) @@ -276,7 +276,7 @@ impl Client { Form: AsyncTryFrom, F: Clone, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .post(self.config.url(path)) @@ -296,7 +296,7 @@ impl Client { Form: AsyncTryFrom, F: Clone, { - let request_maker = async || { + let request_maker = || async { Ok(self .http_client .post(self.config.url(path)) @@ -314,10 +314,11 @@ impl Client { /// request_maker serves one purpose: to be able to create request again /// to retry API call after getting rate limited. request_maker is async because /// reqwest::multipart::Form is created by async calls to read files for uploads. - async fn execute_raw( - &self, - request_maker: impl AsyncFn() -> Result, - ) -> Result { + async fn execute_raw(&self, request_maker: M) -> Result + where + M: Fn() -> Fut, + Fut: future::Future>, + { let client = self.http_client.clone(); let request = request_maker().await?; @@ -355,12 +356,11 @@ impl Client { /// request_maker serves one purpose: to be able to create request again /// to retry API call after getting rate limited. request_maker is async because /// reqwest::multipart::Form is created by async calls to read files for uploads. - async fn execute( - &self, - request_maker: impl AsyncFn() -> Result, - ) -> Result + async fn execute(&self, request_maker: M) -> Result where O: DeserializeOwned, + M: Fn() -> Fut, + Fut: core::future::Future>, { let bytes = self.execute_raw(request_maker).await?;