qdrant_client/builders/
keyword_index_params_builder.rs

1use crate::qdrant::*;
2
3pub struct KeywordIndexParamsBuilder {
4    /// If true - used for tenant optimization.
5    pub(crate) is_tenant: Option<Option<bool>>,
6    /// If true - store index on disk.
7    pub(crate) on_disk: Option<Option<bool>>,
8}
9
10impl Default for KeywordIndexParamsBuilder {
11    fn default() -> Self {
12        Self::create_empty()
13    }
14}
15
16impl KeywordIndexParamsBuilder {
17    /// If true - used for tenant optimization.
18    #[allow(unused_mut)]
19    pub fn is_tenant(self, value: bool) -> Self {
20        let mut new = self;
21        new.is_tenant = Option::Some(Option::Some(value));
22        new
23    }
24    /// If true - store index on disk.
25    #[allow(unused_mut)]
26    pub fn on_disk(self, value: bool) -> Self {
27        let mut new = self;
28        new.on_disk = Option::Some(Option::Some(value));
29        new
30    }
31
32    fn build_inner(self) -> Result<KeywordIndexParams, std::convert::Infallible> {
33        Ok(KeywordIndexParams {
34            is_tenant: self.is_tenant.unwrap_or_default(),
35            on_disk: self.on_disk.unwrap_or_default(),
36        })
37    }
38    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
39    fn create_empty() -> Self {
40        Self {
41            is_tenant: core::default::Default::default(),
42            on_disk: core::default::Default::default(),
43        }
44    }
45}
46
47impl From<KeywordIndexParamsBuilder> for KeywordIndexParams {
48    fn from(value: KeywordIndexParamsBuilder) -> Self {
49        value.build_inner().unwrap_or_else(|_| {
50            panic!(
51                "Failed to convert {0} to {1}",
52                "KeywordIndexParamsBuilder", "KeywordIndexParams"
53            )
54        })
55    }
56}
57
58impl KeywordIndexParamsBuilder {
59    /// Builds the desired type. Can often be omitted.
60    pub fn build(self) -> KeywordIndexParams {
61        self.build_inner().unwrap_or_else(|_| {
62            panic!(
63                "Failed to build {0} into {1}",
64                "KeywordIndexParamsBuilder", "KeywordIndexParams"
65            )
66        })
67    }
68}