asset_locator

Attribute Macro asset_locator 

Source
#[asset_locator]
Expand description

Define an asset locator from a function.

This macro generates a struct and AssetLocator implementation from a locator function, making it easier to define inline locators in tests.

The function name is converted to PascalCase for the struct name. The db parameter name can be anything (commonly _db if unused). The key type is inferred from the second parameter.

§Example

use query_flow::{asset_locator, Db, LocateResult, QueryError};

// Basic locator - returns Pending
#[asset_locator]
fn pending(_db: &impl Db, _key: &ConfigFile) -> Result<LocateResult<String>, QueryError> {
    Ok(LocateResult::Pending)
}

// Generates:
// struct Pending;
// impl AssetLocator<ConfigFile> for Pending { ... }

// Use it:
runtime.register_asset_locator(Pending);