flagsmith_flag_engine/engine_eval/
result.rs

1use super::context::{FeatureMetadata, SegmentMetadata};
2use crate::types::FlagsmithValue;
3use serde::{Deserialize, Serialize};
4use std::collections::HashMap;
5
6/// Represents the result of a feature flag evaluation.
7#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
8pub struct EvaluationResult {
9    /// Map of feature names to their evaluated flag results.
10    pub flags: HashMap<String, FlagResult>,
11
12    /// List of segments that matched during evaluation.
13    #[serde(default)]
14    pub segments: Vec<SegmentResult>,
15}
16
17/// Represents the evaluated result for a single feature flag.
18#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
19pub struct FlagResult {
20    /// Whether the feature is enabled.
21    pub enabled: bool,
22
23    /// The name of the feature.
24    pub name: String,
25
26    /// The reason for this evaluation result (e.g., "DEFAULT", "TARGETING_MATCH; segment=name", "SPLIT; weight=50").
27    pub reason: String,
28
29    /// The value of the feature flag.
30    pub value: FlagsmithValue,
31
32    /// Metadata about the feature.
33    #[serde(default)]
34    pub metadata: FeatureMetadata,
35}
36
37/// Represents a segment that matched during evaluation.
38#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
39pub struct SegmentResult {
40    /// The segment name.
41    pub name: String,
42
43    /// Metadata about the segment.
44    #[serde(default)]
45    pub metadata: SegmentMetadata,
46}