Skip to main content

load_async

Function load_async 

Source
pub async fn load_async<T>(spec: LoadSpec<'static>) -> Result<T, Error>
where T: DeserializeOwned + Send + 'static,
Available on crate feature async only.
Expand description

load, moved off the async executor.

Reading configuration touches the filesystem, which would block the worker it runs on. Where the work actually goes depends on what is available: tokio’s blocking pool with the tokio feature, an executor installed by set_blocking_executor, or a freshly spawned thread. A configuration load happens at startup and on reload, so a thread per call is a real answer rather than a placeholder.

LoadSpec<'static> is taken by value because the work outlives the call; the spec the macro emits satisfies that for free.

§Errors

Same as load, plus an ErrorKind::Backend error if the work never produced a result — a panic inside it, or a runtime shutting down.