loadstar 0.0.7

A simple web framework for rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::future::Future;


pub fn run_async<T>(async_operation: impl Future<Output = T>) -> T {
    // Use `block_in_place` to ensure runtime is dropped in a blocking context
    tokio::task::block_in_place(|| {
        // Get the current Tokio runtime handle
        let handle = tokio::runtime::Handle::current();
        // Run the async operation using the handle and wait for it to complete
        handle.block_on(async_operation)
    })
}