qdrant_client/builders/
set_payload_points_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct SetPayloadPointsBuilder {
6 pub(crate) collection_name: Option<String>,
8 pub(crate) wait: Option<Option<bool>>,
10 pub(crate) payload: Option<::std::collections::HashMap<String, Value>>,
12 points_selector: Option<points_selector::PointsSelectorOneOf>,
14 pub(crate) ordering: Option<Option<WriteOrdering>>,
16 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
18 pub(crate) key: Option<Option<String>>,
20 pub(crate) timeout: Option<Option<u64>>,
22}
23
24impl SetPayloadPointsBuilder {
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 wait(self, value: bool) -> Self {
33 let mut new = self;
34 new.wait = Option::Some(Option::Some(value));
35 new
36 }
37 pub fn payload(self, value: ::std::collections::HashMap<String, Value>) -> Self {
39 let mut new = self;
40 new.payload = Option::Some(value);
41 new
42 }
43 pub fn points_selector<VALUE: core::convert::Into<points_selector::PointsSelectorOneOf>>(
45 self,
46 value: VALUE,
47 ) -> Self {
48 let mut new = self;
49 new.points_selector = Option::Some(value.into());
50 new
51 }
52 pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
54 let mut new = self;
55 new.ordering = Option::Some(Option::Some(value.into()));
56 new
57 }
58 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
60 self,
61 value: VALUE,
62 ) -> Self {
63 let mut new = self;
64 new.shard_key_selector = Option::Some(Option::Some(value.into()));
65 new
66 }
67 pub fn key<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
69 let mut new = self;
70 new.key = Option::Some(Option::Some(value.into()));
71 new
72 }
73 pub fn timeout(self, value: u64) -> Self {
75 let mut new = self;
76 new.timeout = Option::Some(Option::Some(value));
77 new
78 }
79
80 fn build_inner(self) -> Result<SetPayloadPoints, SetPayloadPointsBuilderError> {
81 Ok(SetPayloadPoints {
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 wait: self.wait.unwrap_or_default(),
91 payload: match self.payload {
92 Some(value) => value,
93 None => {
94 return Result::Err(core::convert::Into::into(
95 ::derive_builder::UninitializedFieldError::from("payload"),
96 ));
97 }
98 },
99 points_selector: { convert_option(&self.points_selector) },
100 ordering: self.ordering.unwrap_or_default(),
101 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
102 key: self.key.unwrap_or_default(),
103 timeout: self.timeout.unwrap_or_default(),
104 })
105 }
106 fn create_empty() -> Self {
108 Self {
109 collection_name: core::default::Default::default(),
110 wait: core::default::Default::default(),
111 payload: core::default::Default::default(),
112 points_selector: core::default::Default::default(),
113 ordering: core::default::Default::default(),
114 shard_key_selector: core::default::Default::default(),
115 key: core::default::Default::default(),
116 timeout: core::default::Default::default(),
117 }
118 }
119}
120
121impl From<SetPayloadPointsBuilder> for SetPayloadPoints {
122 fn from(value: SetPayloadPointsBuilder) -> Self {
123 value.build_inner().unwrap_or_else(|_| {
124 panic!(
125 "Failed to convert {0} to {1}",
126 "SetPayloadPointsBuilder", "SetPayloadPoints"
127 )
128 })
129 }
130}
131
132impl SetPayloadPointsBuilder {
133 pub fn build(self) -> SetPayloadPoints {
135 self.build_inner().unwrap_or_else(|_| {
136 panic!(
137 "Failed to build {0} into {1}",
138 "SetPayloadPointsBuilder", "SetPayloadPoints"
139 )
140 })
141 }
142}
143
144impl SetPayloadPointsBuilder {
145 pub(crate) fn empty() -> Self {
146 Self::create_empty()
147 }
148}
149
150#[non_exhaustive]
151#[derive(Debug)]
152pub enum SetPayloadPointsBuilderError {
153 UninitializedField(&'static str),
155 ValidationError(String),
157}
158
159impl std::fmt::Display for SetPayloadPointsBuilderError {
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 SetPayloadPointsBuilderError {}
173
174impl From<derive_builder::UninitializedFieldError> for SetPayloadPointsBuilderError {
176 fn from(error: derive_builder::UninitializedFieldError) -> Self {
177 Self::UninitializedField(error.field_name())
178 }
179}
180
181impl From<String> for SetPayloadPointsBuilderError {
183 fn from(error: String) -> Self {
184 Self::ValidationError(error)
185 }
186}