qdrant_client/builders/
set_payload_points_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[must_use]
5#[derive(Clone)]
6pub struct SetPayloadPointsBuilder {
7 pub(crate) collection_name: Option<String>,
9 pub(crate) wait: Option<Option<bool>>,
11 pub(crate) payload: Option<::std::collections::HashMap<String, Value>>,
13 points_selector: Option<points_selector::PointsSelectorOneOf>,
15 pub(crate) ordering: Option<Option<WriteOrdering>>,
17 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
19 pub(crate) key: Option<Option<String>>,
21 pub(crate) timeout: Option<Option<u64>>,
23}
24
25impl SetPayloadPointsBuilder {
26 pub fn collection_name(self, value: String) -> Self {
28 let mut new = self;
29 new.collection_name = Option::Some(value);
30 new
31 }
32 pub fn wait(self, value: bool) -> Self {
34 let mut new = self;
35 new.wait = Option::Some(Option::Some(value));
36 new
37 }
38 pub fn payload(self, value: ::std::collections::HashMap<String, Value>) -> Self {
40 let mut new = self;
41 new.payload = Option::Some(value);
42 new
43 }
44 pub fn points_selector<VALUE: core::convert::Into<points_selector::PointsSelectorOneOf>>(
46 self,
47 value: VALUE,
48 ) -> Self {
49 let mut new = self;
50 new.points_selector = Option::Some(value.into());
51 new
52 }
53 pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
55 let mut new = self;
56 new.ordering = Option::Some(Option::Some(value.into()));
57 new
58 }
59 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
61 self,
62 value: VALUE,
63 ) -> Self {
64 let mut new = self;
65 new.shard_key_selector = Option::Some(Option::Some(value.into()));
66 new
67 }
68 pub fn key<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
70 let mut new = self;
71 new.key = Option::Some(Option::Some(value.into()));
72 new
73 }
74 pub fn timeout(self, value: u64) -> Self {
76 let mut new = self;
77 new.timeout = Option::Some(Option::Some(value));
78 new
79 }
80
81 fn build_inner(self) -> Result<SetPayloadPoints, SetPayloadPointsBuilderError> {
82 Ok(SetPayloadPoints {
83 collection_name: match self.collection_name {
84 Some(value) => value,
85 None => {
86 return Result::Err(core::convert::Into::into(
87 ::derive_builder::UninitializedFieldError::from("collection_name"),
88 ));
89 }
90 },
91 wait: self.wait.unwrap_or_default(),
92 payload: match self.payload {
93 Some(value) => value,
94 None => {
95 return Result::Err(core::convert::Into::into(
96 ::derive_builder::UninitializedFieldError::from("payload"),
97 ));
98 }
99 },
100 points_selector: { convert_option(&self.points_selector) },
101 ordering: self.ordering.unwrap_or_default(),
102 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
103 key: self.key.unwrap_or_default(),
104 timeout: self.timeout.unwrap_or_default(),
105 })
106 }
107 fn create_empty() -> Self {
109 Self {
110 collection_name: core::default::Default::default(),
111 wait: core::default::Default::default(),
112 payload: core::default::Default::default(),
113 points_selector: core::default::Default::default(),
114 ordering: core::default::Default::default(),
115 shard_key_selector: core::default::Default::default(),
116 key: core::default::Default::default(),
117 timeout: core::default::Default::default(),
118 }
119 }
120}
121
122impl From<SetPayloadPointsBuilder> for SetPayloadPoints {
123 fn from(value: SetPayloadPointsBuilder) -> Self {
124 value.build_inner().unwrap_or_else(|_| {
125 panic!(
126 "Failed to convert {0} to {1}",
127 "SetPayloadPointsBuilder", "SetPayloadPoints"
128 )
129 })
130 }
131}
132
133impl SetPayloadPointsBuilder {
134 pub fn build(self) -> SetPayloadPoints {
136 self.build_inner().unwrap_or_else(|_| {
137 panic!(
138 "Failed to build {0} into {1}",
139 "SetPayloadPointsBuilder", "SetPayloadPoints"
140 )
141 })
142 }
143}
144
145impl SetPayloadPointsBuilder {
146 pub(crate) fn empty() -> Self {
147 Self::create_empty()
148 }
149}
150
151#[non_exhaustive]
152#[derive(Debug)]
153pub enum SetPayloadPointsBuilderError {
154 UninitializedField(&'static str),
156 ValidationError(String),
158}
159
160impl std::fmt::Display for SetPayloadPointsBuilderError {
162 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
163 match self {
164 Self::UninitializedField(field) => {
165 write!(f, "`{field}` must be initialized")
166 }
167 Self::ValidationError(error) => write!(f, "{error}"),
168 }
169 }
170}
171
172impl std::error::Error for SetPayloadPointsBuilderError {}
174
175impl From<derive_builder::UninitializedFieldError> for SetPayloadPointsBuilderError {
177 fn from(error: derive_builder::UninitializedFieldError) -> Self {
178 Self::UninitializedField(error.field_name())
179 }
180}
181
182impl From<String> for SetPayloadPointsBuilderError {
184 fn from(error: String) -> Self {
185 Self::ValidationError(error)
186 }
187}