query_flow/
lib.rs

1//! Query-Flow: A high-level query framework for incremental computation.
2//!
3//! Built on top of [`whale`], this crate provides a user-friendly API for defining
4//! and executing queries with automatic caching and dependency tracking.
5//!
6//! # Key Features
7//!
8//! - **Async-agnostic queries**: Write sync query logic, run with sync or async runtime
9//! - **Automatic caching**: Query results are cached and invalidated based on dependencies
10//! - **Suspense pattern**: Handle async loading with `AssetLoadingState` without coloring functions
11//! - **Type-safe**: Per-query-type caching with compile-time guarantees
12//! - **Early cutoff**: Skip downstream recomputation when values don't change
13//!
14//! # Example
15//!
16//! ```ignore
17//! use query_flow::{query, QueryContext, QueryError, QueryRuntime};
18//!
19//! #[query]
20//! fn add(ctx: &mut QueryContext, a: i32, b: i32) -> Result<i32, QueryError> {
21//!     Ok(a + b)
22//! }
23//!
24//! let runtime = QueryRuntime::new();
25//! let result = runtime.query(Add::new(1, 2)).unwrap();
26//! assert_eq!(*result, 3);
27//! ```
28
29// Allow the macro to reference query_flow types when used inside this crate
30extern crate self as query_flow;
31
32mod asset;
33mod error;
34mod inspector;
35mod key;
36mod loading;
37pub mod output_eq;
38mod query;
39mod runtime;
40mod storage;
41
42pub use asset::{AssetKey, AssetLocator, DurabilityLevel, LocateResult, PendingAsset};
43pub use error::QueryError;
44pub use key::{FullCacheKey, Key};
45pub use loading::AssetLoadingState;
46pub use query::Query;
47pub use query_flow_macros::{asset_key, query};
48pub use runtime::{ErrorComparator, Polled, QueryContext, QueryRuntime, QueryRuntimeBuilder};
49
50// Re-export RevisionCounter from whale for use with poll() and changed_at()
51pub use whale::RevisionCounter;