Skip to main content

with_context

Function with_context 

Source
pub async fn with_context<F, T>(context: Context, f: F) -> T
where F: Future<Output = T>,
Expand description

Attaches a context for the duration of the async function.

§Example

ⓘ
let context = extract_from_headers(&headers);
with_context(context, async {
    // This async block runs with the extracted context
    process_event().await;
}).await;