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