I want to use a Rust async method in Python. I'm trying to use PyO3 or rust-cpython.
For example, for sync Rust functions, I can use,
#[pyfunction]
fn myfunc(a: String) -> PyResult<String> {
let mut contents = String::new();
contents = a.to_string() + " appended";
Ok((contents))
}
#[pymodule]
fn MyModule(py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(urlshot))?;
Ok(())
}
For async methods, how can I do it? For example, I want to call the following method in Python,
async fn hello_world() {
println!("hello, world!");
}