json_eval_rs/rlogic/
config.rs

1/// Configuration options for RLogic engine
2#[derive(Debug, Clone, Copy)]
3pub struct RLogicConfig {
4    /// Enable data mutation tracking (enabled by default, required for safety)
5    /// All data mutations are gated through EvalData when enabled
6    pub enable_tracking: bool,
7    
8    /// Safely ignore NaN errors in math operations (return 0 instead)
9    pub safe_nan_handling: bool,
10    
11    /// Maximum recursion depth for evaluation
12    pub recursion_limit: usize,
13}
14
15impl RLogicConfig {
16    /// Create a new configuration with default settings
17    pub fn new() -> Self {
18        Self::default()
19    }
20    
21    /// Performance-optimized config (tracking disabled, no NaN safety)
22    pub fn performance() -> Self {
23        Self {
24            enable_tracking: false,
25            safe_nan_handling: false,
26            recursion_limit: 1000,
27        }
28    }
29    
30    /// Safety-optimized config (all safety features enabled)
31    pub fn safe() -> Self {
32        Self {
33            enable_tracking: true,
34            safe_nan_handling: true,
35            recursion_limit: 1000,
36        }
37    }
38    
39    /// Minimal config (all features disabled for maximum speed)
40    pub fn minimal() -> Self {
41        Self {
42            enable_tracking: false,
43            safe_nan_handling: false,
44            recursion_limit: 1000,
45        }
46    }
47    
48    /// Builder pattern methods
49    
50    pub fn with_tracking(mut self, enable: bool) -> Self {
51        self.enable_tracking = enable;
52        self
53    }
54    
55    pub fn with_safe_nan(mut self, enable: bool) -> Self {
56        self.safe_nan_handling = enable;
57        self
58    }
59    
60    pub fn with_recursion_limit(mut self, limit: usize) -> Self {
61        self.recursion_limit = limit;
62        self
63    }
64}
65
66impl Default for RLogicConfig {
67    fn default() -> Self {
68        Self {
69            enable_tracking: true,
70            safe_nan_handling: false,
71            recursion_limit: 1000,
72        }
73    }
74}
75