qdrant_client/builders/
get_points_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct GetPointsBuilder {
6 pub(crate) collection_name: Option<String>,
8 pub(crate) ids: Option<Vec<PointId>>,
10 with_payload: Option<with_payload_selector::SelectorOptions>,
12 with_vectors: Option<with_vectors_selector::SelectorOptions>,
14 read_consistency: Option<read_consistency::Value>,
16 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
18 pub(crate) timeout: Option<Option<u64>>,
20}
21
22impl GetPointsBuilder {
23 #[allow(unused_mut)]
25 pub fn collection_name(self, value: String) -> Self {
26 let mut new = self;
27 new.collection_name = Option::Some(value);
28 new
29 }
30 #[allow(unused_mut)]
32 pub fn ids(self, value: Vec<PointId>) -> Self {
33 let mut new = self;
34 new.ids = Option::Some(value);
35 new
36 }
37 #[allow(unused_mut)]
39 pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
40 self,
41 value: VALUE,
42 ) -> Self {
43 let mut new = self;
44 new.with_payload = Option::Some(value.into());
45 new
46 }
47 #[allow(unused_mut)]
49 pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
50 self,
51 value: VALUE,
52 ) -> Self {
53 let mut new = self;
54 new.with_vectors = Option::Some(value.into());
55 new
56 }
57 #[allow(unused_mut)]
59 pub fn read_consistency<VALUE: core::convert::Into<read_consistency::Value>>(
60 self,
61 value: VALUE,
62 ) -> Self {
63 let mut new = self;
64 new.read_consistency = Option::Some(value.into());
65 new
66 }
67 #[allow(unused_mut)]
69 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
70 self,
71 value: VALUE,
72 ) -> Self {
73 let mut new = self;
74 new.shard_key_selector = Option::Some(Option::Some(value.into()));
75 new
76 }
77 #[allow(unused_mut)]
79 pub fn timeout(self, value: u64) -> Self {
80 let mut new = self;
81 new.timeout = Option::Some(Option::Some(value));
82 new
83 }
84
85 fn build_inner(self) -> Result<GetPoints, GetPointsBuilderError> {
86 Ok(GetPoints {
87 collection_name: match self.collection_name {
88 Some(value) => value,
89 None => {
90 return Result::Err(core::convert::Into::into(
91 ::derive_builder::UninitializedFieldError::from("collection_name"),
92 ));
93 }
94 },
95 ids: match self.ids {
96 Some(value) => value,
97 None => {
98 return Result::Err(core::convert::Into::into(
99 ::derive_builder::UninitializedFieldError::from("ids"),
100 ));
101 }
102 },
103 with_payload: { convert_option(&self.with_payload) },
104 with_vectors: { convert_option(&self.with_vectors) },
105 read_consistency: { convert_option(&self.read_consistency) },
106 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
107 timeout: self.timeout.unwrap_or_default(),
108 })
109 }
110 fn create_empty() -> Self {
112 Self {
113 collection_name: core::default::Default::default(),
114 ids: core::default::Default::default(),
115 with_payload: core::default::Default::default(),
116 with_vectors: core::default::Default::default(),
117 read_consistency: core::default::Default::default(),
118 shard_key_selector: core::default::Default::default(),
119 timeout: core::default::Default::default(),
120 }
121 }
122}
123
124impl From<GetPointsBuilder> for GetPoints {
125 fn from(value: GetPointsBuilder) -> Self {
126 value.build_inner().unwrap_or_else(|_| {
127 panic!(
128 "Failed to convert {0} to {1}",
129 "GetPointsBuilder", "GetPoints"
130 )
131 })
132 }
133}
134
135impl GetPointsBuilder {
136 pub fn build(self) -> GetPoints {
138 self.build_inner().unwrap_or_else(|_| {
139 panic!(
140 "Failed to build {0} into {1}",
141 "GetPointsBuilder", "GetPoints"
142 )
143 })
144 }
145}
146
147impl GetPointsBuilder {
148 pub(crate) fn empty() -> Self {
149 Self::create_empty()
150 }
151}
152
153#[non_exhaustive]
155#[derive(Debug)]
156pub enum GetPointsBuilderError {
157 UninitializedField(&'static str),
159 ValidationError(String),
161}
162
163impl From<derive_builder::UninitializedFieldError> for GetPointsBuilderError {
165 fn from(s: derive_builder::UninitializedFieldError) -> Self {
166 Self::UninitializedField(s.field_name())
167 }
168}
169
170impl From<String> for GetPointsBuilderError {
172 fn from(s: String) -> Self {
173 Self::ValidationError(s)
174 }
175}
176
177impl std::fmt::Display for GetPointsBuilderError {
179 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
180 match self {
181 Self::UninitializedField(ref field) => {
182 write!(f, "`{field}` must be initialized")
183 }
184 Self::ValidationError(ref error) => {
185 write!(f, "{error}")
186 }
187 }
188 }
189}
190
191impl std::error::Error for GetPointsBuilderError {}