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