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