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