qdrant_client/builders/
sparse_index_config_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct SparseIndexConfigBuilder {
6 pub(crate) full_scan_threshold: Option<Option<u64>>,
10 pub(crate) on_disk: Option<Option<bool>>,
13 pub(crate) datatype: Option<Option<i32>>,
16 pub(crate) memory: Option<Option<i32>>,
19}
20
21impl SparseIndexConfigBuilder {
22 pub fn full_scan_threshold<VALUE: core::convert::Into<u64>>(self, value: VALUE) -> Self {
26 let mut new = self;
27 new.full_scan_threshold = Option::Some(Option::Some(value.into()));
28 new
29 }
30 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 datatype<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
42 let mut new = self;
43 new.datatype = Option::Some(Option::Some(value.into()));
44 new
45 }
46 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
50 let mut new = self;
51 new.memory = Option::Some(Option::Some(value.into()));
52 new
53 }
54
55 #[allow(deprecated)]
56 fn build_inner(self) -> Result<SparseIndexConfig, std::convert::Infallible> {
57 Ok(SparseIndexConfig {
58 full_scan_threshold: self.full_scan_threshold.unwrap_or_default(),
59 on_disk: self.on_disk.unwrap_or_default(),
60 datatype: self.datatype.unwrap_or_default(),
61 memory: self.memory.unwrap_or_default(),
62 })
63 }
64 fn create_empty() -> Self {
66 Self {
67 full_scan_threshold: core::default::Default::default(),
68 on_disk: core::default::Default::default(),
69 datatype: core::default::Default::default(),
70 memory: core::default::Default::default(),
71 }
72 }
73}
74
75impl From<SparseIndexConfigBuilder> for SparseIndexConfig {
76 fn from(value: SparseIndexConfigBuilder) -> Self {
77 value.build_inner().unwrap_or_else(|_| {
78 panic!(
79 "Failed to convert {0} to {1}",
80 "SparseIndexConfigBuilder", "SparseIndexConfig"
81 )
82 })
83 }
84}
85
86impl SparseIndexConfigBuilder {
87 pub fn build(self) -> SparseIndexConfig {
89 self.build_inner().unwrap_or_else(|_| {
90 panic!(
91 "Failed to build {0} into {1}",
92 "SparseIndexConfigBuilder", "SparseIndexConfig"
93 )
94 })
95 }
96}
97
98impl Default for SparseIndexConfigBuilder {
99 fn default() -> Self {
100 Self::create_empty()
101 }
102}