qdrant_client/builders/
strict_mode_config_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct StrictModeConfigBuilder {
5    pub(crate) enabled: Option<Option<bool>>,
6    pub(crate) max_query_limit: Option<Option<u32>>,
7    pub(crate) max_timeout: Option<Option<u32>>,
8    pub(crate) unindexed_filtering_retrieve: Option<Option<bool>>,
9    pub(crate) unindexed_filtering_update: Option<Option<bool>>,
10    pub(crate) search_max_hnsw_ef: Option<Option<u32>>,
11    pub(crate) search_allow_exact: Option<Option<bool>>,
12    pub(crate) search_max_oversampling: Option<Option<f32>>,
13    pub(crate) upsert_max_batchsize: Option<Option<u64>>,
14    pub(crate) max_collection_vector_size_bytes: Option<Option<u64>>,
15    pub(crate) read_rate_limit: Option<Option<u32>>,
16    pub(crate) write_rate_limit: Option<Option<u32>>,
17    pub(crate) max_collection_payload_size_bytes: Option<Option<u64>>,
18    pub(crate) filter_max_conditions: Option<Option<u64>>,
19    pub(crate) condition_max_size: Option<Option<u64>>,
20    pub(crate) multivector_config: Option<Option<StrictModeMultivectorConfig>>,
21    pub(crate) sparse_config: Option<Option<StrictModeSparseConfig>>,
22    pub(crate) max_points_count: Option<Option<u64>>,
23    pub(crate) max_payload_index_count: Option<Option<u64>>,
24}
25
26impl StrictModeConfigBuilder {
27    pub fn enabled(self, value: bool) -> Self {
28        let mut new = self;
29        new.enabled = Option::Some(Option::Some(value));
30        new
31    }
32
33    pub fn max_query_limit(self, value: u32) -> Self {
34        let mut new = self;
35        new.max_query_limit = Option::Some(Option::Some(value));
36        new
37    }
38
39    pub fn max_timeout(self, value: u32) -> Self {
40        let mut new = self;
41        new.max_timeout = Option::Some(Option::Some(value));
42        new
43    }
44
45    pub fn unindexed_filtering_retrieve(self, value: bool) -> Self {
46        let mut new = self;
47        new.unindexed_filtering_retrieve = Option::Some(Option::Some(value));
48        new
49    }
50
51    pub fn unindexed_filtering_update(self, value: bool) -> Self {
52        let mut new = self;
53        new.unindexed_filtering_update = Option::Some(Option::Some(value));
54        new
55    }
56
57    pub fn search_max_hnsw_ef(self, value: u32) -> Self {
58        let mut new = self;
59        new.search_max_hnsw_ef = Option::Some(Option::Some(value));
60        new
61    }
62
63    pub fn search_allow_exact(self, value: bool) -> Self {
64        let mut new = self;
65        new.search_allow_exact = Option::Some(Option::Some(value));
66        new
67    }
68
69    pub fn search_max_oversampling(self, value: f32) -> Self {
70        let mut new = self;
71        new.search_max_oversampling = Option::Some(Option::Some(value));
72        new
73    }
74
75    pub fn upsert_max_batchsize(self, value: u64) -> Self {
76        let mut new = self;
77        new.upsert_max_batchsize = Option::Some(Option::Some(value));
78        new
79    }
80
81    pub fn max_collection_vector_size_bytes(self, value: u64) -> Self {
82        let mut new = self;
83        new.max_collection_vector_size_bytes = Option::Some(Option::Some(value));
84        new
85    }
86
87    pub fn read_rate_limit(self, value: u32) -> Self {
88        let mut new = self;
89        new.read_rate_limit = Option::Some(Option::Some(value));
90        new
91    }
92
93    pub fn write_rate_limit(self, value: u32) -> Self {
94        let mut new = self;
95        new.write_rate_limit = Option::Some(Option::Some(value));
96        new
97    }
98
99    pub fn max_collection_payload_size_bytes(self, value: u64) -> Self {
100        let mut new = self;
101        new.max_collection_payload_size_bytes = Option::Some(Option::Some(value));
102        new
103    }
104
105    pub fn filter_max_conditions(self, value: u64) -> Self {
106        let mut new = self;
107        new.filter_max_conditions = Option::Some(Option::Some(value));
108        new
109    }
110
111    pub fn condition_max_size(self, value: u64) -> Self {
112        let mut new = self;
113        new.condition_max_size = Option::Some(Option::Some(value));
114        new
115    }
116
117    pub fn multivector_config(self, value: impl Into<StrictModeMultivectorConfig>) -> Self {
118        let mut new = self;
119        new.multivector_config = Option::Some(Option::Some(value.into()));
120        new
121    }
122
123    pub fn sparse_config(self, value: impl Into<StrictModeSparseConfig>) -> Self {
124        let mut new = self;
125        new.sparse_config = Option::Some(Option::Some(value.into()));
126        new
127    }
128
129    pub fn max_points_count(self, value: u64) -> Self {
130        let mut new = self;
131        new.max_points_count = Option::Some(Option::Some(value));
132        new
133    }
134
135    pub fn max_payload_index_count(self, value: u64) -> Self {
136        let mut new = self;
137        new.max_payload_index_count = Option::Some(Option::Some(value));
138        new
139    }
140
141    fn build_inner(self) -> Result<StrictModeConfig, std::convert::Infallible> {
142        Ok(StrictModeConfig {
143            enabled: self.enabled.unwrap_or_default(),
144            max_query_limit: self.max_query_limit.unwrap_or_default(),
145            max_timeout: self.max_timeout.unwrap_or_default(),
146            unindexed_filtering_retrieve: self.unindexed_filtering_retrieve.unwrap_or_default(),
147            unindexed_filtering_update: self.unindexed_filtering_update.unwrap_or_default(),
148            search_max_hnsw_ef: self.search_max_hnsw_ef.unwrap_or_default(),
149            search_allow_exact: self.search_allow_exact.unwrap_or_default(),
150            search_max_oversampling: self.search_max_oversampling.unwrap_or_default(),
151            upsert_max_batchsize: self.upsert_max_batchsize.unwrap_or_default(),
152            max_collection_vector_size_bytes: self
153                .max_collection_vector_size_bytes
154                .unwrap_or_default(),
155            read_rate_limit: self.read_rate_limit.unwrap_or_default(),
156            write_rate_limit: self.write_rate_limit.unwrap_or_default(),
157            max_collection_payload_size_bytes: self
158                .max_collection_payload_size_bytes
159                .unwrap_or_default(),
160            filter_max_conditions: self.filter_max_conditions.unwrap_or_default(),
161            condition_max_size: self.condition_max_size.unwrap_or_default(),
162            multivector_config: self.multivector_config.unwrap_or_default(),
163            sparse_config: self.sparse_config.unwrap_or_default(),
164            max_points_count: self.max_points_count.unwrap_or_default(),
165            max_payload_index_count: self.max_payload_index_count.unwrap_or_default(),
166        })
167    }
168    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
169    fn create_empty() -> Self {
170        Self {
171            enabled: core::default::Default::default(),
172            max_query_limit: core::default::Default::default(),
173            max_timeout: core::default::Default::default(),
174            unindexed_filtering_retrieve: core::default::Default::default(),
175            unindexed_filtering_update: core::default::Default::default(),
176            search_max_hnsw_ef: core::default::Default::default(),
177            search_allow_exact: core::default::Default::default(),
178            search_max_oversampling: core::default::Default::default(),
179            upsert_max_batchsize: core::default::Default::default(),
180            max_collection_vector_size_bytes: core::default::Default::default(),
181            read_rate_limit: core::default::Default::default(),
182            write_rate_limit: core::default::Default::default(),
183            max_collection_payload_size_bytes: core::default::Default::default(),
184            filter_max_conditions: core::default::Default::default(),
185            condition_max_size: core::default::Default::default(),
186            multivector_config: core::default::Default::default(),
187            sparse_config: core::default::Default::default(),
188            max_points_count: core::default::Default::default(),
189            max_payload_index_count: core::default::Default::default(),
190        }
191    }
192}
193
194impl Default for StrictModeConfigBuilder {
195    fn default() -> Self {
196        Self::create_empty()
197    }
198}
199
200impl From<StrictModeConfigBuilder> for StrictModeConfig {
201    fn from(value: StrictModeConfigBuilder) -> Self {
202        value.build_inner().unwrap_or_else(|_| {
203            panic!(
204                "Failed to convert {0} to {1}",
205                "StrictModeConfigBuilder", "StrictModeConfig"
206            )
207        })
208    }
209}
210
211impl StrictModeConfigBuilder {
212    /// Builds the desired type. Can often be omitted.
213    pub fn build(self) -> StrictModeConfig {
214        self.build_inner().unwrap_or_else(|_| {
215            panic!(
216                "Failed to build {0} into {1}",
217                "StrictModeConfigBuilder", "StrictModeConfig"
218            )
219        })
220    }
221}