qdrant_client/builders/
delete_point_vectors_builder.rs

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