condition_matcher/
result.rs1use crate::{condition::{ConditionMode, ConditionOperator}, error::MatchError};
2
3#[derive(Debug, Clone)]
5pub struct MatchResult {
6 pub matched: bool,
8 pub condition_results: Vec<ConditionResult>,
10 pub mode: ConditionMode,
12}
13
14impl MatchResult {
15 pub fn is_match(&self) -> bool {
17 self.matched
18 }
19
20 pub fn passed_conditions(&self) -> Vec<&ConditionResult> {
22 self.condition_results.iter().filter(|r| r.passed).collect()
23 }
24
25 pub fn failed_conditions(&self) -> Vec<&ConditionResult> {
27 self.condition_results
28 .iter()
29 .filter(|r| !r.passed)
30 .collect()
31 }
32}
33
34#[derive(Debug, Clone)]
36pub struct ConditionResult {
37 pub passed: bool,
39 pub description: String,
41 pub actual_value: Option<String>,
43 pub expected_value: Option<String>,
45 pub error: Option<MatchError>,
47}
48#[cfg(feature = "json_condition")]
50#[derive(Debug, Clone)]
51pub struct JsonConditionResult {
52 pub passed: bool,
54 pub field: String,
56 pub operator: ConditionOperator,
58 pub expected: serde_json::Value,
60 pub actual: Option<serde_json::Value>,
62 pub error: Option<String>,
64}
65
66#[cfg(feature = "json_condition")]
68#[derive(Debug, Clone)]
69pub struct JsonEvalResult {
70 pub matched: bool,
72 pub details: Vec<JsonConditionResult>,
74}