qdrant_client/builders/
delete_point_vectors_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct DeletePointVectorsBuilder {
6 pub(crate) collection_name: Option<String>,
8 pub(crate) wait: Option<Option<bool>>,
10 points_selector: Option<points_selector::PointsSelectorOneOf>,
12 pub(crate) vectors: Option<Option<VectorsSelector>>,
14 pub(crate) ordering: Option<Option<WriteOrdering>>,
16 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
18 pub(crate) timeout: Option<Option<u64>>,
20}
21
22impl DeletePointVectorsBuilder {
23 pub fn collection_name(self, value: String) -> Self {
25 let mut new = self;
26 new.collection_name = Option::Some(value);
27 new
28 }
29 pub fn wait(self, value: bool) -> Self {
31 let mut new = self;
32 new.wait = Option::Some(Option::Some(value));
33 new
34 }
35 pub fn points_selector<VALUE: core::convert::Into<points_selector::PointsSelectorOneOf>>(
37 self,
38 value: VALUE,
39 ) -> Self {
40 let mut new = self;
41 new.points_selector = Option::Some(value.into());
42 new
43 }
44 pub fn vectors<VALUE: core::convert::Into<VectorsSelector>>(self, value: VALUE) -> Self {
46 let mut new = self;
47 new.vectors = Option::Some(Option::Some(value.into()));
48 new
49 }
50 pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
52 let mut new = self;
53 new.ordering = Option::Some(Option::Some(value.into()));
54 new
55 }
56 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
58 self,
59 value: VALUE,
60 ) -> Self {
61 let mut new = self;
62 new.shard_key_selector = Option::Some(Option::Some(value.into()));
63 new
64 }
65 pub fn timeout(self, value: u64) -> Self {
67 let mut new = self;
68 new.timeout = Option::Some(Option::Some(value));
69 new
70 }
71
72 fn build_inner(self) -> Result<DeletePointVectors, DeletePointVectorsBuilderError> {
73 Ok(DeletePointVectors {
74 collection_name: match self.collection_name {
75 Some(value) => value,
76 None => {
77 return Result::Err(core::convert::Into::into(
78 ::derive_builder::UninitializedFieldError::from("collection_name"),
79 ));
80 }
81 },
82 wait: self.wait.unwrap_or_default(),
83 points_selector: { convert_option(&self.points_selector) },
84 vectors: self.vectors.unwrap_or_default(),
85 ordering: self.ordering.unwrap_or_default(),
86 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
87 timeout: self.timeout.unwrap_or_default(),
88 })
89 }
90 fn create_empty() -> Self {
92 Self {
93 collection_name: core::default::Default::default(),
94 wait: core::default::Default::default(),
95 points_selector: core::default::Default::default(),
96 vectors: core::default::Default::default(),
97 ordering: core::default::Default::default(),
98 shard_key_selector: core::default::Default::default(),
99 timeout: core::default::Default::default(),
100 }
101 }
102}
103
104impl From<DeletePointVectorsBuilder> for DeletePointVectors {
105 fn from(value: DeletePointVectorsBuilder) -> Self {
106 value.build_inner().unwrap_or_else(|_| {
107 panic!(
108 "Failed to convert {0} to {1}",
109 "DeletePointVectorsBuilder", "DeletePointVectors"
110 )
111 })
112 }
113}
114
115impl DeletePointVectorsBuilder {
116 pub fn build(self) -> DeletePointVectors {
118 self.build_inner().unwrap_or_else(|_| {
119 panic!(
120 "Failed to build {0} into {1}",
121 "DeletePointVectorsBuilder", "DeletePointVectors"
122 )
123 })
124 }
125}
126
127impl DeletePointVectorsBuilder {
128 pub(crate) fn empty() -> Self {
129 Self::create_empty()
130 }
131}
132
133#[non_exhaustive]
135#[derive(Debug)]
136pub enum DeletePointVectorsBuilderError {
137 UninitializedField(&'static str),
139 ValidationError(String),
141}
142
143impl std::fmt::Display for DeletePointVectorsBuilderError {
145 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
146 match self {
147 Self::UninitializedField(field) => {
148 write!(f, "`{field}` must be initialized")
149 }
150 Self::ValidationError(error) => write!(f, "{error}"),
151 }
152 }
153}
154
155impl std::error::Error for DeletePointVectorsBuilderError {}
157
158impl From<derive_builder::UninitializedFieldError> for DeletePointVectorsBuilderError {
160 fn from(error: derive_builder::UninitializedFieldError) -> Self {
161 Self::UninitializedField(error.field_name())
162 }
163}
164
165impl From<String> for DeletePointVectorsBuilderError {
167 fn from(error: String) -> Self {
168 Self::ValidationError(error)
169 }
170}