This should be possible with Rust's coroutines support, see https://doc.rust-lang.org/nightly/unstable-book/language-features/generators.html and https://github.com/rust-lang/rust/issues/43122. We might need to provide our own macros similar to https://github.com/alexcrichton/futures-await.