task_storage

Attribute Macro task_storage 

Source
#[task_storage]
Expand description

Derives the TaskStorage struct and generates optimized storage structures.

This macro analyzes field annotations and generates:

  1. A unified TaskStorage struct
  2. LazyField enum for lazy_vec fields
  3. Typed accessor methods on TaskStorage
  4. TaskStorageAccessors trait with accessor methods
  5. TaskFlags bitfield for boolean flags

§Field Attributes

All fields require two attributes:

§storage = "..." (required)

Specifies how the field is stored:

  • direct - Direct field access (e.g., Option<OutputValue>)
  • auto_set - Uses AutoSet for small collections
  • auto_map - Uses AutoMap for key-value pairs
  • counter_map - Uses CounterMap for reference counting
  • flag - Boolean flag stored in a compact TaskFlags bitfield (field type must be bool)

§category = "..." (required)

Specifies the data category for persistence and access:

  • data - Frequently changed, bulk I/O
  • meta - Rarely changed, small I/O
  • transient - Field is not serialized (in-memory only)

§Optional Modifiers

  • inline - Field is stored inline on TaskStorage (default is lazy). Only use for hot-path fields that are frequently accessed.
  • default - Use Default::default() semantics instead of Option for inline direct fields.
  • filter_transient - Filter out transient values during serialization.
  • Serialization methods