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
LoadingStatewithout 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§
- Pending
Asset - A pending asset request that needs to be resolved.
- Query
Context - Context provided to queries during execution.
- Query
Runtime - The query runtime manages query execution, caching, and dependency tracking.
- Query
Runtime Builder - Builder for
QueryRuntimewith customizable settings.
Enums§
- Durability
Level - Named durability levels for assets and queries.
- Loading
State - Represents the loading state of an async resource.
- Locate
Result - Result of locating an asset.
- Query
Error - Query errors including both system-level and user errors.
Traits§
- Asset
Key - Trait for asset keys that map to loadable assets.
- Asset
Locator - Trait for locating and loading assets.
- Key
- Trait for query cache keys.
- Query
- A query that can be executed and cached.
Type Aliases§
- Error
Comparator - Function type for comparing user errors during early cutoff.