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 pub fn collection_name(self, value: String) -> Self {
26 let mut new = self;
27 new.collection_name = Option::Some(value);
28 new
29 }
30 pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
32 let mut new = self;
33 new.filter = Option::Some(Option::Some(value.into()));
34 new
35 }
36 pub fn sample(self, value: u64) -> Self {
38 let mut new = self;
39 new.sample = Option::Some(Option::Some(value));
40 new
41 }
42 pub fn limit(self, value: u64) -> Self {
44 let mut new = self;
45 new.limit = Option::Some(Option::Some(value));
46 new
47 }
48 pub fn using<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
50 let mut new = self;
51 new.using = Option::Some(Option::Some(value.into()));
52 new
53 }
54 pub fn timeout(self, value: u64) -> Self {
56 let mut new = self;
57 new.timeout = Option::Some(Option::Some(value));
58 new
59 }
60 pub fn read_consistency<VALUE: core::convert::Into<ReadConsistency>>(
62 self,
63 value: VALUE,
64 ) -> Self {
65 let mut new = self;
66 new.read_consistency = Option::Some(Option::Some(value.into()));
67 new
68 }
69 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
71 self,
72 value: VALUE,
73 ) -> Self {
74 let mut new = self;
75 new.shard_key_selector = Option::Some(Option::Some(value.into()));
76 new
77 }
78
79 fn build_inner(self) -> Result<SearchMatrixPoints, SearchMatrixPointsBuilderError> {
80 Ok(SearchMatrixPoints {
81 collection_name: match self.collection_name {
82 Some(value) => value,
83 None => {
84 return Result::Err(core::convert::Into::into(
85 ::derive_builder::UninitializedFieldError::from("collection_name"),
86 ));
87 }
88 },
89 filter: self.filter.unwrap_or_default(),
90 sample: self.sample.unwrap_or_default(),
91 limit: self.limit.unwrap_or_default(),
92 using: self.using.unwrap_or_default(),
93 timeout: self.timeout.unwrap_or_default(),
94 read_consistency: self.read_consistency.unwrap_or_default(),
95 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
96 })
97 }
98 fn create_empty() -> Self {
100 Self {
101 collection_name: core::default::Default::default(),
102 filter: core::default::Default::default(),
103 sample: core::default::Default::default(),
104 limit: core::default::Default::default(),
105 using: core::default::Default::default(),
106 timeout: core::default::Default::default(),
107 read_consistency: core::default::Default::default(),
108 shard_key_selector: core::default::Default::default(),
109 }
110 }
111}
112
113impl From<SearchMatrixPointsBuilder> for SearchMatrixPoints {
114 fn from(value: SearchMatrixPointsBuilder) -> Self {
115 value.build_inner().unwrap_or_else(|_| {
116 panic!(
117 "Failed to convert {0} to {1}",
118 "SearchMatrixPointsBuilder", "SearchMatrixPoints"
119 )
120 })
121 }
122}
123
124impl SearchMatrixPointsBuilder {
125 pub fn build(self) -> SearchMatrixPoints {
127 self.build_inner().unwrap_or_else(|_| {
128 panic!(
129 "Failed to build {0} into {1}",
130 "SearchMatrixPointsBuilder", "SearchMatrixPoints"
131 )
132 })
133 }
134}
135
136impl SearchMatrixPointsBuilder {
137 pub(crate) fn empty() -> Self {
138 Self::create_empty()
139 }
140}
141
142#[non_exhaustive]
143#[derive(Debug)]
144pub enum SearchMatrixPointsBuilderError {
145 UninitializedField(&'static str),
147 ValidationError(String),
149}
150
151impl std::fmt::Display for SearchMatrixPointsBuilderError {
153 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
154 match self {
155 Self::UninitializedField(field) => {
156 write!(f, "`{field}` must be initialized")
157 }
158 Self::ValidationError(error) => write!(f, "{error}"),
159 }
160 }
161}
162
163impl std::error::Error for SearchMatrixPointsBuilderError {}
165
166impl From<derive_builder::UninitializedFieldError> for SearchMatrixPointsBuilderError {
168 fn from(error: derive_builder::UninitializedFieldError) -> Self {
169 Self::UninitializedField(error.field_name())
170 }
171}
172
173impl From<String> for SearchMatrixPointsBuilderError {
175 fn from(error: String) -> Self {
176 Self::ValidationError(error)
177 }
178}