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 LoadingState 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§

PendingAsset
A pending asset request that needs to be resolved.
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.
LoadingState
Represents the loading state of an async resource.
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.

Attribute Macros§

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