future_fn

Attribute Macro future_fn 

Source
#[future_fn]
Expand description

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

This attribute macro wraps async functions with the future! macro, enabling tracking of poll counts, state transitions (pending/ready/cancelled), and optionally logging the result value.

§Parameters

  • log - If true, logs the result value when the future completes (requires Debug on return type)

§Examples

Basic usage (no Debug requirement on return type):

#[hotpath::future_fn]
async fn fetch_data() -> Vec<u8> {
    // This future's lifecycle will be tracked
    vec![1, 2, 3]
}

With result logging (requires Debug on return type):

#[hotpath::future_fn(log = true)]
async fn compute() -> i32 {
    // The result value will be logged in TUI console
    42
}

§See Also

  • measure - Attribute macro for instrumenting sync/async function timing
  • future! - Declarative macro for instrumenting future expressions