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