qdrant_client/builders/
update_point_vectors_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct UpdatePointVectorsBuilder {
5    /// name of the collection
6    pub(crate) collection_name: Option<String>,
7    /// Wait until the changes have been applied?
8    pub(crate) wait: Option<Option<bool>>,
9    /// List of points and vectors to update
10    pub(crate) points: Option<Vec<PointVectors>>,
11    /// Write ordering guarantees
12    pub(crate) ordering: Option<Option<WriteOrdering>>,
13    /// Option for custom sharding to specify used shard keys
14    pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
15    /// Optional filter to apply to the update operation. If set, only points matching the filter will be updated.
16    pub(crate) update_filter: Option<Option<Filter>>,
17}
18
19impl UpdatePointVectorsBuilder {
20    /// name of the collection
21    pub fn collection_name(self, value: String) -> Self {
22        let mut new = self;
23        new.collection_name = Option::Some(value);
24        new
25    }
26    /// Wait until the changes have been applied?
27    pub fn wait(self, value: bool) -> Self {
28        let mut new = self;
29        new.wait = Option::Some(Option::Some(value));
30        new
31    }
32    /// List of points and vectors to update
33    pub fn points(self, value: Vec<PointVectors>) -> Self {
34        let mut new = self;
35        new.points = Option::Some(value);
36        new
37    }
38    /// Write ordering guarantees
39    pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
40        let mut new = self;
41        new.ordering = Option::Some(Option::Some(value.into()));
42        new
43    }
44    /// Option for custom sharding to specify used shard keys
45    pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
46        self,
47        value: VALUE,
48    ) -> Self {
49        let mut new = self;
50        new.shard_key_selector = Option::Some(Option::Some(value.into()));
51        new
52    }
53    /// Optional filter to apply to the update operation. If set, only points matching the filter will be updated.
54    pub fn update_filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
55        let mut new = self;
56        new.update_filter = Option::Some(Option::Some(value.into()));
57        new
58    }
59
60    fn build_inner(self) -> Result<UpdatePointVectors, UpdatePointVectorsBuilderError> {
61        Ok(UpdatePointVectors {
62            collection_name: match self.collection_name {
63                Some(value) => value,
64                None => {
65                    return Result::Err(core::convert::Into::into(
66                        ::derive_builder::UninitializedFieldError::from("collection_name"),
67                    ));
68                }
69            },
70            wait: self.wait.unwrap_or_default(),
71            points: match self.points {
72                Some(value) => value,
73                None => {
74                    return Result::Err(core::convert::Into::into(
75                        ::derive_builder::UninitializedFieldError::from("points"),
76                    ));
77                }
78            },
79            ordering: self.ordering.unwrap_or_default(),
80            shard_key_selector: self.shard_key_selector.unwrap_or_default(),
81            update_filter: self.update_filter.unwrap_or_default(),
82        })
83    }
84    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
85    fn create_empty() -> Self {
86        Self {
87            collection_name: core::default::Default::default(),
88            wait: core::default::Default::default(),
89            points: core::default::Default::default(),
90            ordering: core::default::Default::default(),
91            shard_key_selector: core::default::Default::default(),
92            update_filter: core::default::Default::default(),
93        }
94    }
95}
96
97impl From<UpdatePointVectorsBuilder> for UpdatePointVectors {
98    fn from(value: UpdatePointVectorsBuilder) -> Self {
99        value.build_inner().unwrap_or_else(|_| {
100            panic!(
101                "Failed to convert {0} to {1}",
102                "UpdatePointVectorsBuilder", "UpdatePointVectors"
103            )
104        })
105    }
106}
107
108impl UpdatePointVectorsBuilder {
109    /// Builds the desired type. Can often be omitted.
110    pub fn build(self) -> UpdatePointVectors {
111        self.build_inner().unwrap_or_else(|_| {
112            panic!(
113                "Failed to build {0} into {1}",
114                "UpdatePointVectorsBuilder", "UpdatePointVectors"
115            )
116        })
117    }
118}
119
120impl UpdatePointVectorsBuilder {
121    pub(crate) fn empty() -> Self {
122        Self::create_empty()
123    }
124}
125
126#[non_exhaustive]
127#[derive(Debug)]
128pub enum UpdatePointVectorsBuilderError {
129    /// Uninitialized field
130    UninitializedField(&'static str),
131    /// Custom validation error
132    ValidationError(String),
133}
134
135// Implementing the Display trait for better error messages
136impl std::fmt::Display for UpdatePointVectorsBuilderError {
137    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
138        match self {
139            Self::UninitializedField(field) => {
140                write!(f, "`{field}` must be initialized")
141            }
142            Self::ValidationError(error) => write!(f, "{error}"),
143        }
144    }
145}
146
147// Implementing the Error trait
148impl std::error::Error for UpdatePointVectorsBuilderError {}
149
150// Implementing From trait for conversion from UninitializedFieldError
151impl From<derive_builder::UninitializedFieldError> for UpdatePointVectorsBuilderError {
152    fn from(error: derive_builder::UninitializedFieldError) -> Self {
153        Self::UninitializedField(error.field_name())
154    }
155}
156
157// Implementing From trait for conversion from String
158impl From<String> for UpdatePointVectorsBuilderError {
159    fn from(error: String) -> Self {
160        Self::ValidationError(error)
161    }
162}