Crate query_flow

Crate query_flow 

Source
Expand description

Query-Flow: A high-level query framework for incremental computation.

Built on top of whale, this crate provides a user-friendly API for defining and executing queries with automatic caching and dependency tracking.

§Key Features

  • Async-agnostic queries: Write sync query logic, run with sync or async runtime
  • Automatic caching: Query results are cached and invalidated based on dependencies
  • Suspense pattern: Handle async loading with AssetLoadingState without coloring functions
  • Type-safe: Per-query-type caching with compile-time guarantees
  • Early cutoff: Skip downstream recomputation when values don’t change

§Example

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

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

let runtime = QueryRuntime::new();
let result = runtime.query(Add::new(1, 2)).unwrap();
assert_eq!(*result, 3);

Modules§

output_eq
Utility functions for output equality comparison in queries.

Structs§

AssetLoadingState
Loading state with asset key information for error reporting.
FullCacheKey
Full cache key that includes query type information.
PendingAsset
A pending asset request that needs to be resolved.
Polled
Result of polling a query, containing the value and its revision.
QueryContext
Context provided to queries during execution.
QueryRuntime
The query runtime manages query execution, caching, and dependency tracking.
QueryRuntimeBuilder
Builder for QueryRuntime with customizable settings.

Enums§

DurabilityLevel
Named durability levels for assets and queries.
LocateResult
Result of locating an asset.
QueryError
Query errors including both system-level and user errors.

Traits§

AssetKey
Trait for asset keys that map to loadable assets.
AssetLocator
Trait for locating and loading assets.
Key
Trait for query cache keys.
Query
A query that can be executed and cached.

Type Aliases§

ErrorComparator
Function type for comparing user errors during early cutoff.
RevisionCounter
Revision counter type - monotonically increasing counter for tracking changes.

Attribute Macros§

asset_key
Define an asset key type.
query
Define a query from a function.