qdrant_client/builders/
keyword_index_params_builder.rs

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