This commit is contained in:
2025-07-14 21:18:57 -04:00
parent e18eb7bb02
commit 820f5445a3

View File

@ -14,15 +14,13 @@ pub fn http_response(_attr: TokenStream, item: TokenStream) -> TokenStream {
let impl_block = match &ast.data { let impl_block = match &ast.data {
Data::Struct(_) => { Data::Struct(_) => {
quote! { quote! {
#[async_trait::async_trait]
impl Responsable for #name impl Responsable for #name
where where
Self: serde::de::DeserializeOwned + Sized, Self: serde::de::DeserializeOwned + Sized + Send,
{ {
fn receive(resp: awc::ClientResponse) -> Result<Self, Box<dyn std::error::Error>> { async fn receive(mut resp: actix_web::ClientResponse) -> Result<Self, Box<dyn std::error::Error>> {
let parsed = actix_web::rt::System::new() let parsed = resp.json::<Self>().await
.block_on(async {
resp.json::<Self>().await
})
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
Ok(parsed) Ok(parsed)
} }
@ -47,12 +45,10 @@ pub fn http_response(_attr: TokenStream, item: TokenStream) -> TokenStream {
}); });
quote! { quote! {
#[async_trait::async_trait]
impl Responsable for #name { impl Responsable for #name {
fn receive(resp: awc::ClientResponse) -> Result<Self, Box<dyn std::error::Error>> { async fn receive(mut resp: actix_web::ClientResponse) -> Result<Self, Box<dyn std::error::Error>> {
let body = actix_web::rt::System::new() let body = resp.body().await
.block_on(async {
resp.body().await
})
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?; .map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e.to_string()))?;
#(#variant_arms)* #(#variant_arms)*