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}
17
18impl SparseIndexConfigBuilder {
19 pub fn full_scan_threshold<VALUE: core::convert::Into<u64>>(self, value: VALUE) -> Self {
23 let mut new = self;
24 new.full_scan_threshold = Option::Some(Option::Some(value.into()));
25 new
26 }
27 pub fn on_disk(self, value: bool) -> Self {
30 let mut new = self;
31 new.on_disk = Option::Some(Option::Some(value));
32 new
33 }
34 pub fn datatype<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
37 let mut new = self;
38 new.datatype = Option::Some(Option::Some(value.into()));
39 new
40 }
41
42 fn build_inner(self) -> Result<SparseIndexConfig, std::convert::Infallible> {
43 Ok(SparseIndexConfig {
44 full_scan_threshold: self.full_scan_threshold.unwrap_or_default(),
45 on_disk: self.on_disk.unwrap_or_default(),
46 datatype: self.datatype.unwrap_or_default(),
47 })
48 }
49 fn create_empty() -> Self {
51 Self {
52 full_scan_threshold: core::default::Default::default(),
53 on_disk: core::default::Default::default(),
54 datatype: core::default::Default::default(),
55 }
56 }
57}
58
59impl From<SparseIndexConfigBuilder> for SparseIndexConfig {
60 fn from(value: SparseIndexConfigBuilder) -> Self {
61 value.build_inner().unwrap_or_else(|_| {
62 panic!(
63 "Failed to convert {0} to {1}",
64 "SparseIndexConfigBuilder", "SparseIndexConfig"
65 )
66 })
67 }
68}
69
70impl SparseIndexConfigBuilder {
71 pub fn build(self) -> SparseIndexConfig {
73 self.build_inner().unwrap_or_else(|_| {
74 panic!(
75 "Failed to build {0} into {1}",
76 "SparseIndexConfigBuilder", "SparseIndexConfig"
77 )
78 })
79 }
80}
81
82impl Default for SparseIndexConfigBuilder {
83 fn default() -> Self {
84 Self::create_empty()
85 }
86}