core only.Expand description
Layer 0: Transport-agnostic query lifecycle primitives.
QueryResource owns the cache/request state for one resource. Callers start
work with begin_request, then complete it with the returned RequestId.
Completion methods reject stale request ids, so cancelled or replaced async
work cannot overwrite newer state.
§Request lifecycle
The typical lifecycle for a single query fetch is:
-
Begin: Call
QueryResource::begin_requestwith aRequestSequencer. This returns aQueryBeginResultindicating whether a fetch is needed, the cache was hit, or the request was ignored. -
Fetch: If the result is
StartedorStaleCacheHit, start an async fetch using the returnedRequestId. -
Accept: When the fetch completes, call
QueryResource::accept_current_requestwith theRequestId. If the request is still active (not replaced or cancelled), this returns aRequestGuard— a single-use capability token. -
Complete: Pass the
RequestGuard(by value) toQueryResource::complete_successorQueryResource::complete_failure. The guard is consumed, preventing accidental double-completion.
Alternatively, use the convenience methods QueryResource::complete_current_success
or QueryResource::complete_current_failure which combine steps 3 and 4.
This module depends only on serde — zero framework coupling.
Structs§
- Fetched
- A fetcher success carrying an optional server-derived cache policy.
- Infinite
Query Resource - An infinite query resource that manages paginated data.
- Mapped
Query Resource - A mapped view over a
QueryResourcethat applies aSelectTransform. - Mutation
Resource - A mutation resource that tracks the state of a single mutation.
- Query
Error - An error produced by a query or mutation operation.
- Query
Key - A structured, hierarchical cache key for query resources.
- Query
Resource - Core state machine for a single query resource.
- Query
Signal - A cooperative cancellation signal for in-flight query requests.
- Query
Timestamp - A timestamp for query operations, in milliseconds since UNIX epoch.
- Request
Guard - A single-use capability token proving the holder owns the current request.
- Request
Id - A unique identifier for an in-flight request.
- Request
Sequencer - Monotonic request id generator scoped to a single resource.
- Retry
Policy - Retry configuration for failed requests.
- Select
Transform - A select transform that maps cached data of type
Tto output typeU.
Enums§
- Cache
Policy - How cached data is treated when a query is accessed.
- Fetch
Direction - Direction mode for an infinite query.
- Mutation
Status - Status of a mutation operation.
- Network
Mode - Controls fetch behavior based on network connectivity.
- Query
Begin Result - The result of calling
begin_requeston a query resource. - Query
Error Kind - The kind of error that occurred during a query operation.
- Query
Fetch Mode - Whether the fetch is a normal request or forced (ignoring cache).
- Query
KeyFilter - A filter for matching query keys, used by bulk operations like
invalidate_queries. - Query
Status - The status of a query resource.
- Refetch
Trigger - Trigger configuration for automatic refetching.
- Request
Policy - How concurrent requests are handled.