qdrant_client/builders/
quantization_search_params_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct QuantizationSearchParamsBuilder {
5 pub(crate) ignore: Option<Option<bool>>,
8 pub(crate) rescore: Option<Option<bool>>,
11 pub(crate) oversampling: Option<Option<f64>>,
20}
21
22impl QuantizationSearchParamsBuilder {
23 pub fn ignore(self, value: bool) -> Self {
26 let mut new = self;
27 new.ignore = Option::Some(Option::Some(value));
28 new
29 }
30 pub fn rescore(self, value: bool) -> Self {
33 let mut new = self;
34 new.rescore = Option::Some(Option::Some(value));
35 new
36 }
37 pub fn oversampling(self, value: f64) -> Self {
46 let mut new = self;
47 new.oversampling = Option::Some(Option::Some(value));
48 new
49 }
50
51 fn build_inner(self) -> Result<QuantizationSearchParams, std::convert::Infallible> {
52 Ok(QuantizationSearchParams {
53 ignore: self.ignore.unwrap_or_default(),
54 rescore: self.rescore.unwrap_or_default(),
55 oversampling: self.oversampling.unwrap_or_default(),
56 })
57 }
58 fn create_empty() -> Self {
60 Self {
61 ignore: core::default::Default::default(),
62 rescore: core::default::Default::default(),
63 oversampling: core::default::Default::default(),
64 }
65 }
66}
67
68impl Default for QuantizationSearchParamsBuilder {
69 fn default() -> Self {
70 Self::create_empty()
71 }
72}
73
74impl From<QuantizationSearchParamsBuilder> for QuantizationSearchParams {
75 fn from(value: QuantizationSearchParamsBuilder) -> Self {
76 value.build_inner().unwrap_or_else(|_| {
77 panic!(
78 "Failed to convert {0} to {1}",
79 "QuantizationSearchParamsBuilder", "QuantizationSearchParams"
80 )
81 })
82 }
83}
84
85impl QuantizationSearchParamsBuilder {
86 pub fn build(self) -> QuantizationSearchParams {
88 self.build_inner().unwrap_or_else(|_| {
89 panic!(
90 "Failed to build {0} into {1}",
91 "QuantizationSearchParamsBuilder", "QuantizationSearchParams"
92 )
93 })
94 }
95}