rs_query/lib.rs
1//! rs-query: TanStack Query-inspired data fetching for GPUI
2//!
3//! # Features
4//!
5//! - **Declarative queries** - Define once, auto-cache
6//! - **spawn_query/spawn_mutation** - One-liner async execution
7//! - **Stale-while-revalidate** - Show cached data while fetching
8//! - **Automatic retries** - Exponential backoff for transient failures
9//! - **Cache invalidation** - Hierarchical key patterns
10//!
11//! # Example
12//!
13//! ```rust,ignore
14//! use rs_query::{QueryClient, QueryKey, QueryState, Query, spawn_query};
15//!
16//! // Define a query
17//! let query = Query::new(QueryKey::new("users"), || async {
18//! fetch_users().await
19//! });
20//!
21//! // Execute with automatic state management
22//! spawn_query(cx, &client, &query, |this, state, cx| {
23//! match state {
24//! QueryState::Success(users) => this.users = users,
25//! QueryState::Error { error, .. } => this.error = Some(error),
26//! _ => {}
27//! }
28//! cx.notify();
29//! });
30//! ```
31
32mod client;
33mod error;
34mod executor;
35mod key;
36mod mutation;
37mod options;
38mod query;
39mod state;
40
41pub use client::QueryClient;
42pub use error::QueryError;
43pub use executor::{spawn_mutation, spawn_query};
44pub use key::QueryKey;
45pub use mutation::{Mutation, MutationState};
46pub use options::{QueryOptions, RefetchOnMount, RetryConfig};
47pub use query::Query;
48pub use state::QueryState;