qdrant_client/builders/
keyword_index_params_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct KeywordIndexParamsBuilder {
6 pub(crate) is_tenant: Option<Option<bool>>,
8 pub(crate) on_disk: Option<Option<bool>>,
10 pub(crate) enable_hnsw: Option<Option<bool>>,
12 pub(crate) prefix: Option<Option<KeywordPrefixParams>>,
14 pub(crate) memory: Option<Option<i32>>,
16}
17
18impl Default for KeywordIndexParamsBuilder {
19 fn default() -> Self {
20 Self::create_empty()
21 }
22}
23
24impl KeywordIndexParamsBuilder {
25 pub fn is_tenant(self, value: bool) -> Self {
27 let mut new = self;
28 new.is_tenant = Option::Some(Option::Some(value));
29 new
30 }
31 pub fn on_disk(self, value: bool) -> Self {
35 let mut new = self;
36 new.on_disk = Option::Some(Option::Some(value));
37 new
38 }
39 pub fn enable_hnsw(self, value: bool) -> Self {
41 let mut new = self;
42 new.enable_hnsw = Option::Some(Option::Some(value));
43 new
44 }
45 pub fn prefix(self, value: bool) -> Self {
47 let mut new = self;
48 new.prefix = Option::Some(value.then(KeywordPrefixParams::default));
49 new
50 }
51 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
54 let mut new = self;
55 new.memory = Option::Some(Option::Some(value.into()));
56 new
57 }
58
59 #[allow(deprecated)]
60 fn build_inner(self) -> Result<KeywordIndexParams, std::convert::Infallible> {
61 Ok(KeywordIndexParams {
62 is_tenant: self.is_tenant.unwrap_or_default(),
63 on_disk: self.on_disk.unwrap_or_default(),
64 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
65 prefix: self.prefix.unwrap_or_default(),
66 memory: self.memory.unwrap_or_default(),
67 })
68 }
69 fn create_empty() -> Self {
71 Self {
72 is_tenant: core::default::Default::default(),
73 on_disk: core::default::Default::default(),
74 enable_hnsw: core::default::Default::default(),
75 prefix: core::default::Default::default(),
76 memory: core::default::Default::default(),
77 }
78 }
79}
80
81impl From<KeywordIndexParamsBuilder> for KeywordIndexParams {
82 fn from(value: KeywordIndexParamsBuilder) -> Self {
83 value.build_inner().unwrap_or_else(|_| {
84 panic!(
85 "Failed to convert {0} to {1}",
86 "KeywordIndexParamsBuilder", "KeywordIndexParams"
87 )
88 })
89 }
90}
91
92impl KeywordIndexParamsBuilder {
93 pub fn build(self) -> KeywordIndexParams {
95 self.build_inner().unwrap_or_else(|_| {
96 panic!(
97 "Failed to build {0} into {1}",
98 "KeywordIndexParamsBuilder", "KeywordIndexParams"
99 )
100 })
101 }
102}