qdrant_client/builders/
sparse_index_config_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct SparseIndexConfigBuilder {
5 pub(crate) full_scan_threshold: Option<Option<u64>>,
9 pub(crate) on_disk: Option<Option<bool>>,
12 pub(crate) datatype: Option<Option<i32>>,
15}
16
17impl SparseIndexConfigBuilder {
18 pub fn full_scan_threshold<VALUE: core::convert::Into<u64>>(self, value: VALUE) -> Self {
22 let mut new = self;
23 new.full_scan_threshold = Option::Some(Option::Some(value.into()));
24 new
25 }
26 pub fn on_disk(self, value: bool) -> Self {
29 let mut new = self;
30 new.on_disk = Option::Some(Option::Some(value));
31 new
32 }
33 pub fn datatype<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
36 let mut new = self;
37 new.datatype = Option::Some(Option::Some(value.into()));
38 new
39 }
40
41 fn build_inner(self) -> Result<SparseIndexConfig, std::convert::Infallible> {
42 Ok(SparseIndexConfig {
43 full_scan_threshold: self.full_scan_threshold.unwrap_or_default(),
44 on_disk: self.on_disk.unwrap_or_default(),
45 datatype: self.datatype.unwrap_or_default(),
46 })
47 }
48 fn create_empty() -> Self {
50 Self {
51 full_scan_threshold: core::default::Default::default(),
52 on_disk: core::default::Default::default(),
53 datatype: core::default::Default::default(),
54 }
55 }
56}
57
58impl From<SparseIndexConfigBuilder> for SparseIndexConfig {
59 fn from(value: SparseIndexConfigBuilder) -> Self {
60 value.build_inner().unwrap_or_else(|_| {
61 panic!(
62 "Failed to convert {0} to {1}",
63 "SparseIndexConfigBuilder", "SparseIndexConfig"
64 )
65 })
66 }
67}
68
69impl SparseIndexConfigBuilder {
70 pub fn build(self) -> SparseIndexConfig {
72 self.build_inner().unwrap_or_else(|_| {
73 panic!(
74 "Failed to build {0} into {1}",
75 "SparseIndexConfigBuilder", "SparseIndexConfig"
76 )
77 })
78 }
79}
80
81impl Default for SparseIndexConfigBuilder {
82 fn default() -> Self {
83 Self::create_empty()
84 }
85}