query_flow/
query.rs

1pub mod context;
2pub mod result;
3
4use context::QueryContext;
5
6use crate::{error::Error, key::Key};
7
8pub trait Query {
9    type CacheKey: Key;
10    type Output;
11
12    /// Get the cache key for the query.
13    fn cache_key(&self) -> Self::CacheKey;
14
15    /// Query the output of the query.
16    fn query(&self, ctx: &mut QueryContext) -> Result<Self::Output, Error>;
17
18    /// Whether the query should never be cached.
19    ///
20    /// If true, this query will always be re-calculated. Even if not cached, downstream queries can be cached.
21    fn never_cache(&self) -> bool {
22        false
23    }
24}