open_feature/evaluation/
options.rs

1use crate::Hook;
2
3/// Contain hooks.
4#[derive(Default, Clone)]
5pub struct EvaluationOptions {
6    /// The hooks to be used during evaluation.
7    pub hooks: Vec<crate::hooks::HookWrapper>,
8
9    /// Hints to be passed to the hooks.
10    pub hints: crate::hooks::HookHints,
11}
12
13impl EvaluationOptions {
14    /// Create a new instance of `EvaluationOptions`.
15    pub fn new(hooks: Vec<crate::hooks::HookWrapper>, hints: crate::hooks::HookHints) -> Self {
16        Self { hooks, hints }
17    }
18
19    /// Add a hook to the evaluation options.
20    #[must_use]
21    pub fn with_hook<T: Hook + 'static>(mut self, hook: T) -> Self {
22        self.hooks.push(crate::hooks::HookWrapper::new(hook));
23        self
24    }
25}