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