pub fn asks_config<U, Env, F>(
f: F,
) -> impl Effect<Output = U, Error = AnalysisError, Env = Env>where
U: Send + 'static,
Env: AnalysisEnv + Clone + Send + Sync + 'static,
F: Fn(&DebtmapConfig) -> U + Send + Sync + 'static,Expand description
Query config through closure - the core Reader pattern primitive.
This function creates an effect that queries the environment’s config
using a provided closure. The closure receives a reference to the
DebtmapConfig and returns any value.
Uses Arc internally to allow the closure to be called multiple times.
§Type Parameters
U: The return type of the queryEnv: The environment type (must implementAnalysisEnv)F: The query function type
§Example
ⓘ
use debtmap::effects::asks_config;
// Get ignore patterns from config
fn get_ignore_patterns<Env>() -> impl Effect<Output = Vec<String>, Error = AnalysisError, Env = Env>
where
Env: AnalysisEnv + Clone + Send + Sync,
{
asks_config(|config| config.get_ignore_patterns())
}
// Get complexity threshold
fn get_complexity_threshold<Env>() -> impl Effect<Output = Option<u32>, Error = AnalysisError, Env = Env>
where
Env: AnalysisEnv + Clone + Send + Sync,
{
asks_config(|config| config.thresholds.as_ref().and_then(|t| t.complexity))
}