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