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