Skip to main content

block_on

Function block_on 

pub fn block_on<F>(future: F) -> Result<<F as Future>::Output, Error>
where F: Future,
Expand description

Run future to completion on the calling thread.

For synchronous entry points only: a CLI’s main, a test, a dedicated worker thread that owns no runtime. The runtime lives for this call; a process that waits on async work repeatedly should keep a runtime (the app() runtime, or one built with daemon()) and use its handle.

§Errors

Error::UiThread on a UI thread, Error::InsideRuntime inside a runtime context, Error::Start when the runtime cannot be built.