Skip to main content

statsig_rust/gcir/
gcir_options.rs

1use serde::Deserialize;
2use std::collections::HashSet;
3
4use crate::{GCIRResponseFormat, HashAlgorithm};
5
6#[derive(Deserialize)]
7pub struct ClientInitResponseOptions {
8    pub hash_algorithm: Option<HashAlgorithm>,
9    pub client_sdk_key: Option<String>,
10    pub include_local_overrides: Option<bool>,
11    pub feature_gate_filter: Option<HashSet<String>>,
12    pub experiment_filter: Option<HashSet<String>>,
13    pub dynamic_config_filter: Option<HashSet<String>>,
14    pub layer_filter: Option<HashSet<String>>,
15    pub param_store_filter: Option<HashSet<String>>,
16    pub response_format: Option<GCIRResponseFormat>,
17    pub remove_id_type: Option<bool>,
18    pub remove_default_value_gates: Option<bool>,
19    pub previous_response_hash: Option<String>,
20    pub remove_experiments_in_layers: Option<bool>,
21}
22
23impl ClientInitResponseOptions {
24    pub(crate) fn get_hash_algorithm(&self) -> &HashAlgorithm {
25        self.hash_algorithm.as_ref().unwrap_or(&HashAlgorithm::Djb2)
26    }
27}
28
29impl Default for ClientInitResponseOptions {
30    fn default() -> Self {
31        Self {
32            hash_algorithm: Some(HashAlgorithm::Djb2),
33            client_sdk_key: None,
34            include_local_overrides: Some(false),
35            feature_gate_filter: None,
36            experiment_filter: None,
37            dynamic_config_filter: None,
38            layer_filter: None,
39            param_store_filter: None,
40            response_format: None,
41            remove_id_type: Some(false),
42            remove_default_value_gates: Some(false),
43            previous_response_hash: None,
44            remove_experiments_in_layers: Some(false),
45        }
46    }
47}