Skip to main content

intermediate

Attribute Macro intermediate 

Source
#[intermediate]
Expand description

Procedural macro for defining intermediate computations directly on functions

Usage:

// Assumes ComputeDouble struct is already defined
#[intermediate(id = 1)]
fn compute_double(_context: &ComputeDouble, db: &DbHandle<MyStorage>) -> i32 {
    db.get(InputValue) * 2
}

This generates a call to define_intermediate! using the extracted information. Assumes the computation struct is already defined.

Required attributes:

  • id: The computation ID (integer)

Optional attribute:

  • assume_changed: If present, indicates that the input is assumed to have changed

The macro automatically extracts:

  • Output type from the function return type (i32)
  • Computation type from the first parameter (ComputeDouble from &ComputeDouble)
  • Storage type from the second parameter (MyStorage from &DbHandle<MyStorage>)
  • Function name automatically (compute_double)