query

Attribute Macro query 

Source
#[query]
Expand description

Define a query from a function.

§Attributes

  • durability = N: Set durability level (0-255, default 0)
  • output_eq = path: Custom equality function (default: PartialEq)
  • keys(a, b, ...): Specify which params form the cache key
  • name = "Name": Override generated struct name

§Example

use query_flow::{query, QueryContext, QueryError};

// Basic query - all params are keys
#[query]
fn add(ctx: &mut QueryContext, a: i32, b: i32) -> Result<i32, QueryError> {
    Ok(a + b)
}

// With options
#[query(durability = 2, keys(id))]
pub fn fetch_user(ctx: &mut QueryContext, id: u64, include_deleted: bool) -> Result<User, QueryError> {
    // include_deleted is NOT part of the cache key
    Ok(load_user(id, include_deleted))
}