Generate a blocking method for each async method in an impl block. Supports either tokio
or async-std
backend.
Generated methods are suffixed with _blocking
.
# Example tokio
```
use blockon::blockon;
struct Tokio {}
#[blockon("tokio")]
impl Tokio {
async fn testasync(&self) {}
}
```
Generates the following impl block ```norun # struct Dummy {} # impl Dummy { async fn testasync(&self) {}
fn testasyncblocking(&self) { use tokio::runtime::Runtime; let mut rt = Runtime::new().unwrap(); rt.blockon(self.testasync()) } # } ```
# Example async-std
```
use blockon::blockon;
struct AsyncStd {}
#[blockon("async-std")]
impl AsyncStd {
async fn testasync(&self) {}
}
```
Generates the following method in the same impl block ```norun # struct Dummy {} # impl Dummy { async fn testasync(&self) {}
fn testasyncblocking(&self) { use asyncstd::task; task::blockon(self.test_async()) } # } ```