From b54620b5aaf6d83246e1bad6e19c8da6095ae5ac Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Sat, 21 Sep 2024 15:44:27 -0400 Subject: [PATCH] fix(client): use async_recursion crate --- Cargo.lock | 12 ++++++++++++ Cargo.toml | 1 + src/client.rs | 3 ++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index a7dfbc0..df122ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -116,6 +116,17 @@ dependencies = [ "nom", ] +[[package]] +name = "async-recursion" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.68", +] + [[package]] name = "async-trait" version = "0.1.80" @@ -1219,6 +1230,7 @@ version = "0.35.1" dependencies = [ "arc-swap", "askama", + "async-recursion", "base64 0.22.1", "brotli", "build_html", diff --git a/Cargo.toml b/Cargo.toml index 451a83a..c6f8ac7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ pretty_env_logger = "0.5.0" dotenvy = "0.15.7" rss = "2.0.7" arc-swap = "1.7.1" +async-recursion = "1.1.1" [dev-dependencies] diff --git a/src/client.rs b/src/client.rs index 6a202ff..72e6bae 100644 --- a/src/client.rs +++ b/src/client.rs @@ -64,6 +64,7 @@ static URL_PAIRS: [(&str, &str); 2] = [ /// `Location` header. An `Err(String)` is returned if Reddit responds with a /// 429, or if we were unable to decode the value in the `Location` header. #[cached(size = 1024, time = 600, result = true)] +#[async_recursion::async_recursion] pub async fn canonical_path(path: String, tries: i8) -> Result, String> { if tries == 0 { return Ok(None); @@ -113,7 +114,7 @@ pub async fn canonical_path(path: String, tries: i8) -> Result, S let uri = format_url(stripped_uri); // Decrement tries and try again - Box::pin(canonical_path(uri, tries - 1)).await + canonical_path(uri, tries - 1).await } None => Ok(None), },