qdrant_client/builders/
search_matrix_points_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct SearchMatrixPointsBuilder {
5 pub(crate) collection_name: Option<String>,
7 pub(crate) filter: Option<Option<Filter>>,
9 pub(crate) sample: Option<Option<u64>>,
11 pub(crate) limit: Option<Option<u64>>,
13 pub(crate) using: Option<Option<String>>,
15 pub(crate) timeout: Option<Option<u64>>,
17 pub(crate) read_consistency: Option<Option<ReadConsistency>>,
19 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
21}
22
23impl SearchMatrixPointsBuilder {
24 #[allow(unused_mut)]
26 pub fn collection_name(self, value: String) -> Self {
27 let mut new = self;
28 new.collection_name = Option::Some(value);
29 new
30 }
31 #[allow(unused_mut)]
33 pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
34 let mut new = self;
35 new.filter = Option::Some(Option::Some(value.into()));
36 new
37 }
38 #[allow(unused_mut)]
40 pub fn sample(self, value: u64) -> Self {
41 let mut new = self;
42 new.sample = Option::Some(Option::Some(value));
43 new
44 }
45 #[allow(unused_mut)]
47 pub fn limit(self, value: u64) -> Self {
48 let mut new = self;
49 new.limit = Option::Some(Option::Some(value));
50 new
51 }
52 #[allow(unused_mut)]
54 pub fn using<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
55 let mut new = self;
56 new.using = Option::Some(Option::Some(value.into()));
57 new
58 }
59 #[allow(unused_mut)]
61 pub fn timeout(self, value: u64) -> Self {
62 let mut new = self;
63 new.timeout = Option::Some(Option::Some(value));
64 new
65 }
66 #[allow(unused_mut)]
68 pub fn read_consistency<VALUE: core::convert::Into<ReadConsistency>>(
69 self,
70 value: VALUE,
71 ) -> Self {
72 let mut new = self;
73 new.read_consistency = Option::Some(Option::Some(value.into()));
74 new
75 }
76 #[allow(unused_mut)]
78 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
79 self,
80 value: VALUE,
81 ) -> Self {
82 let mut new = self;
83 new.shard_key_selector = Option::Some(Option::Some(value.into()));
84 new
85 }
86
87 fn build_inner(self) -> Result<SearchMatrixPoints, SearchMatrixPointsBuilderError> {
88 Ok(SearchMatrixPoints {
89 collection_name: match self.collection_name {
90 Some(value) => value,
91 None => {
92 return Result::Err(core::convert::Into::into(
93 ::derive_builder::UninitializedFieldError::from("collection_name"),
94 ));
95 }
96 },
97 filter: self.filter.unwrap_or_default(),
98 sample: self.sample.unwrap_or_default(),
99 limit: self.limit.unwrap_or_default(),
100 using: self.using.unwrap_or_default(),
101 timeout: self.timeout.unwrap_or_default(),
102 read_consistency: self.read_consistency.unwrap_or_default(),
103 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
104 })
105 }
106 fn create_empty() -> Self {
108 Self {
109 collection_name: core::default::Default::default(),
110 filter: core::default::Default::default(),
111 sample: core::default::Default::default(),
112 limit: core::default::Default::default(),
113 using: core::default::Default::default(),
114 timeout: core::default::Default::default(),
115 read_consistency: core::default::Default::default(),
116 shard_key_selector: core::default::Default::default(),
117 }
118 }
119}
120
121impl From<SearchMatrixPointsBuilder> for SearchMatrixPoints {
122 fn from(value: SearchMatrixPointsBuilder) -> Self {
123 value.build_inner().unwrap_or_else(|_| {
124 panic!(
125 "Failed to convert {0} to {1}",
126 "SearchMatrixPointsBuilder", "SearchMatrixPoints"
127 )
128 })
129 }
130}
131
132impl SearchMatrixPointsBuilder {
133 pub fn build(self) -> SearchMatrixPoints {
135 self.build_inner().unwrap_or_else(|_| {
136 panic!(
137 "Failed to build {0} into {1}",
138 "SearchMatrixPointsBuilder", "SearchMatrixPoints"
139 )
140 })
141 }
142}
143
144impl SearchMatrixPointsBuilder {
145 pub(crate) fn empty() -> Self {
146 Self::create_empty()
147 }
148}
149
150#[non_exhaustive]
151#[derive(Debug)]
152pub enum SearchMatrixPointsBuilderError {
153 UninitializedField(&'static str),
155 ValidationError(String),
157}
158
159impl std::fmt::Display for SearchMatrixPointsBuilderError {
161 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
162 match self {
163 Self::UninitializedField(field) => {
164 write!(f, "`{field}` must be initialized")
165 }
166 Self::ValidationError(error) => write!(f, "{error}"),
167 }
168 }
169}
170
171impl std::error::Error for SearchMatrixPointsBuilderError {}
173
174impl From<derive_builder::UninitializedFieldError> for SearchMatrixPointsBuilderError {
176 fn from(error: derive_builder::UninitializedFieldError) -> Self {
177 Self::UninitializedField(error.field_name())
178 }
179}
180
181impl From<String> for SearchMatrixPointsBuilderError {
183 fn from(error: String) -> Self {
184 Self::ValidationError(error)
185 }
186}