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