Skip to main content

qdrant_client/builders/
delete_point_vectors_builder.rs

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