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.
A thread already inside a runtime context — a worker, a block_on, a
blocking-pool thread, or code that entered a handle — is refused: it
cannot hand this thread to a second runtime, and tokio panics when it
tries. Await the future there instead, or AppRuntime::block_on, which
polls on the calling thread.
§Errors
Error::UiThread on a UI thread, Error::InsideRuntime inside any
runtime context, Error::Start when the runtime cannot be built.