pub struct LocalEvaluator { /* private fields */ }Expand description
Evaluates feature flags using locally cached definitions.
The evaluator reads from a FlagCache to determine flag values without
making network requests. Supports cohort membership checks and flag
dependencies through the evaluation context.
Implementations§
Source§impl LocalEvaluator
impl LocalEvaluator
Sourcepub fn cache(&self) -> &FlagCache
pub fn cache(&self) -> &FlagCache
Access the underlying flag cache (e.g. to read group type mappings).
Sourcepub fn evaluate_flag(
&self,
key: &str,
distinct_id: &str,
person_properties: &HashMap<String, Value>,
groups: &HashMap<String, String>,
group_properties: &HashMap<String, HashMap<String, Value>>,
) -> Result<Option<FlagValue>, InconclusiveMatchError>
pub fn evaluate_flag( &self, key: &str, distinct_id: &str, person_properties: &HashMap<String, Value>, groups: &HashMap<String, String>, group_properties: &HashMap<String, HashMap<String, Value>>, ) -> Result<Option<FlagValue>, InconclusiveMatchError>
Evaluate a feature flag locally with full context support.
Supports cohort membership checks, flag dependency evaluation, and
group / mixed-targeting flags. groups and group_properties are
only consulted when the flag (or one of its conditions) targets a
group via aggregation_group_type_index; pass empty maps for
person-targeted flags.
§Returns
Ok(Some(value)) when the flag is present and evaluated,
Ok(None) when the flag is absent from the cache.
§Errors
Returns InconclusiveMatchError when required properties, cohorts, or
dependent flags are unavailable locally.
Sourcepub fn evaluate_flag_simple(
&self,
key: &str,
distinct_id: &str,
person_properties: &HashMap<String, Value>,
groups: &HashMap<String, String>,
group_properties: &HashMap<String, HashMap<String, Value>>,
) -> Result<Option<FlagValue>, InconclusiveMatchError>
pub fn evaluate_flag_simple( &self, key: &str, distinct_id: &str, person_properties: &HashMap<String, Value>, groups: &HashMap<String, String>, group_properties: &HashMap<String, HashMap<String, Value>>, ) -> Result<Option<FlagValue>, InconclusiveMatchError>
Evaluate a feature flag locally without cohort or flag dependency support.
Use this when you know the flag doesn’t have cohort or flag dependency conditions.
§Returns
Ok(Some(value)) when the flag is present and evaluated,
Ok(None) when the flag is absent from the cache.
§Errors
Returns InconclusiveMatchError when required properties are
unavailable locally.
Sourcepub fn evaluate_all_flags(
&self,
distinct_id: &str,
person_properties: &HashMap<String, Value>,
groups: &HashMap<String, String>,
group_properties: &HashMap<String, HashMap<String, Value>>,
) -> HashMap<String, Result<FlagValue, InconclusiveMatchError>>
pub fn evaluate_all_flags( &self, distinct_id: &str, person_properties: &HashMap<String, Value>, groups: &HashMap<String, String>, group_properties: &HashMap<String, HashMap<String, Value>>, ) -> HashMap<String, Result<FlagValue, InconclusiveMatchError>>
Get all flags and evaluate them with full context support.
The returned map is keyed by feature flag key. Each value can be an inconclusive error if that particular flag could not be evaluated from the supplied context.
Trait Implementations§
Source§impl Clone for LocalEvaluator
impl Clone for LocalEvaluator
Source§fn clone(&self) -> LocalEvaluator
fn clone(&self) -> LocalEvaluator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more