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