qdrant_client/builders/
update_batch_points_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct UpdateBatchPointsBuilder {
6 pub(crate) collection_name: Option<String>,
8 pub(crate) wait: Option<Option<bool>>,
10 pub(crate) operations: Option<Vec<PointsUpdateOperation>>,
11 pub(crate) ordering: Option<Option<WriteOrdering>>,
13 pub(crate) timeout: Option<Option<u64>>,
15}
16
17impl UpdateBatchPointsBuilder {
18 pub fn collection_name(self, value: String) -> Self {
20 let mut new = self;
21 new.collection_name = Option::Some(value);
22 new
23 }
24 pub fn wait(self, value: bool) -> Self {
26 let mut new = self;
27 new.wait = Option::Some(Option::Some(value));
28 new
29 }
30 pub fn operations(self, value: Vec<PointsUpdateOperation>) -> Self {
31 let mut new = self;
32 new.operations = Option::Some(value);
33 new
34 }
35 pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
37 let mut new = self;
38 new.ordering = Option::Some(Option::Some(value.into()));
39 new
40 }
41 pub fn timeout(self, value: u64) -> Self {
43 let mut new = self;
44 new.timeout = Option::Some(Option::Some(value));
45 new
46 }
47
48 fn build_inner(self) -> Result<UpdateBatchPoints, UpdateBatchPointsBuilderError> {
49 Ok(UpdateBatchPoints {
50 collection_name: match self.collection_name {
51 Some(value) => value,
52 None => {
53 return Result::Err(core::convert::Into::into(
54 ::derive_builder::UninitializedFieldError::from("collection_name"),
55 ));
56 }
57 },
58 wait: self.wait.unwrap_or_default(),
59 operations: match self.operations {
60 Some(value) => value,
61 None => {
62 return Result::Err(core::convert::Into::into(
63 ::derive_builder::UninitializedFieldError::from("operations"),
64 ));
65 }
66 },
67 ordering: self.ordering.unwrap_or_default(),
68 timeout: self.timeout.unwrap_or_default(),
69 })
70 }
71 fn create_empty() -> Self {
73 Self {
74 collection_name: core::default::Default::default(),
75 wait: core::default::Default::default(),
76 operations: core::default::Default::default(),
77 ordering: core::default::Default::default(),
78 timeout: core::default::Default::default(),
79 }
80 }
81}
82
83impl From<UpdateBatchPointsBuilder> for UpdateBatchPoints {
84 fn from(value: UpdateBatchPointsBuilder) -> Self {
85 value.build_inner().unwrap_or_else(|_| {
86 panic!(
87 "Failed to convert {0} to {1}",
88 "UpdateBatchPointsBuilder", "UpdateBatchPoints"
89 )
90 })
91 }
92}
93
94impl UpdateBatchPointsBuilder {
95 pub fn build(self) -> UpdateBatchPoints {
97 self.build_inner().unwrap_or_else(|_| {
98 panic!(
99 "Failed to build {0} into {1}",
100 "UpdateBatchPointsBuilder", "UpdateBatchPoints"
101 )
102 })
103 }
104}
105
106impl UpdateBatchPointsBuilder {
107 pub(crate) fn empty() -> Self {
108 Self::create_empty()
109 }
110}
111
112#[non_exhaustive]
113#[derive(Debug)]
114pub enum UpdateBatchPointsBuilderError {
115 UninitializedField(&'static str),
117 ValidationError(String),
119}
120
121impl std::fmt::Display for UpdateBatchPointsBuilderError {
123 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
124 match self {
125 Self::UninitializedField(field) => {
126 write!(f, "`{field}` must be initialized")
127 }
128 Self::ValidationError(error) => write!(f, "{error}"),
129 }
130 }
131}
132
133impl std::error::Error for UpdateBatchPointsBuilderError {}
135
136impl From<derive_builder::UninitializedFieldError> for UpdateBatchPointsBuilderError {
138 fn from(error: derive_builder::UninitializedFieldError) -> Self {
139 Self::UninitializedField(error.field_name())
140 }
141}
142
143impl From<String> for UpdateBatchPointsBuilderError {
145 fn from(error: String) -> Self {
146 Self::ValidationError(error)
147 }
148}