Skip to main content

future_fn

Attribute Macro future_fn 

Source
#[future_fn]
Expand description

Instruments an async function to track its lifecycle as a Future.

Wraps the function body with the future! macro to track poll counts, state transitions (pending/ready/cancelled), and optionally the output value. Can only be applied to async fn.

§Parameters

  • log - If true, logs the output value on completion (requires Debug on return type)

§Examples

#[hotpath::future_fn]
async fn fetch_data() -> Vec<u8> {
    vec![1, 2, 3]
}

#[hotpath::future_fn(log = true)]
async fn compute() -> i32 {
    42
}

§See Also

  • measure - Instruments execution time / allocations
  • future! - Declarative macro for wrapping future expressions