optify/provider/
get_options_preferences.rs1use crate::provider::{constraints::Constraints, SourceValue};
2
3#[derive(Clone, Hash, PartialEq, Eq)]
4pub struct GetOptionsPreferences {
5 pub are_configurable_strings_enabled: bool,
9 pub constraints: Option<Constraints>,
10 pub overrides: Option<SourceValue>,
12 pub skip_feature_name_conversion: bool,
15}
16
17impl Default for GetOptionsPreferences {
18 fn default() -> Self {
19 Self::new()
20 }
21}
22
23impl GetOptionsPreferences {
24 pub fn new() -> Self {
25 Self {
26 are_configurable_strings_enabled: false,
27 constraints: None,
28 overrides: None,
29 skip_feature_name_conversion: false,
30 }
31 }
32
33 pub fn set_constraints(&mut self, constraints: Option<serde_json::Value>) {
34 self.constraints = constraints.map(|c| Constraints { constraints: c });
35 }
36
37 pub fn set_constraints_json(&mut self, constraints: Option<&str>) {
38 self.constraints = constraints.map(|c| Constraints {
39 constraints: serde_json::from_str(c).expect("constraints should be valid JSON"),
40 });
41 }
42}