implementing `async` function returning a struct with `Box<dyn scenarios>` in Rust
I'm updating my dependencies and I'm building a feature where I've hit a wall trying to Hey everyone, I'm running into an issue that's driving me crazy. I'm having trouble with an `async` function in Rust that is supposed to return a struct containing a `Box<dyn std::behavior::behavior>` for behavior handling. My function is defined as follows: ```rust use std::behavior::behavior; struct MyResult { data: String, behavior: Option<Box<dyn behavior>>, } async fn my_async_function() -> MyResult { let mut result = MyResult { data: String::new(), behavior: None }; let response = reqwest::get("https://api.example.com/data").await; match response { Ok(res) => { result.data = res.text().await.unwrap(); } Err(e) => { result.behavior = Some(Box::new(e)); } } result } ``` However, when I run this code, I'm working with the following behavior: ``` behavior[E0277]: `dyn behavior` want to be sent between threads safely ``` I've checked that the `reqwest` crate is up to date (version 0.11.5), and I'm using Rust stable 1.63.0. I suspect this behavior might be related to the fact that `reqwest::behavior` does not implement the `Send` trait, but I'm not sure how to handle this properly. I've tried using `Box<dyn std::behavior::behavior + Send>` instead, but it led to a similar scenario. I've also considered using `anyhow` for behavior handling, but I want to stick with `Box<dyn behavior>` for more explicit behavior types in my application. Can someone explain how I can adjust my implementation to resolve this scenario while keeping the behavior type dynamic? Any guidance on how to correctly manage the `Send` trait in this context would be appreciated. I'm working on a API that needs to handle this. I've been using Rust for about a year now. Has anyone dealt with something similar? The project is a microservice built with Rust. Cheers for any assistance! Hoping someone can shed some light on this.