qdrant_client/builders/
delete_field_index_collection_builder.rs

1use crate::qdrant::*;
2
3pub struct DeleteFieldIndexCollectionBuilder {
4    /// name of the collection
5    pub(crate) collection_name: Option<String>,
6    /// Wait until the changes have been applied?
7    pub(crate) wait: Option<Option<bool>>,
8    /// Field name to delete
9    pub(crate) field_name: Option<String>,
10    /// Write ordering guarantees
11    pub(crate) ordering: Option<Option<WriteOrdering>>,
12}
13
14impl DeleteFieldIndexCollectionBuilder {
15    /// name of the collection
16    #[allow(unused_mut)]
17    pub fn collection_name(self, value: String) -> Self {
18        let mut new = self;
19        new.collection_name = Option::Some(value);
20        new
21    }
22    /// Wait until the changes have been applied?
23    #[allow(unused_mut)]
24    pub fn wait(self, value: bool) -> Self {
25        let mut new = self;
26        new.wait = Option::Some(Option::Some(value));
27        new
28    }
29    /// Field name to delete
30    #[allow(unused_mut)]
31    pub fn field_name(self, value: String) -> Self {
32        let mut new = self;
33        new.field_name = Option::Some(value);
34        new
35    }
36    /// Write ordering guarantees
37    #[allow(unused_mut)]
38    pub fn ordering(self, value: WriteOrdering) -> Self {
39        let mut new = self;
40        new.ordering = Option::Some(Option::Some(value));
41        new
42    }
43
44    fn build_inner(
45        self,
46    ) -> Result<DeleteFieldIndexCollection, DeleteFieldIndexCollectionBuilderError> {
47        Ok(DeleteFieldIndexCollection {
48            collection_name: match self.collection_name {
49                Some(value) => value,
50                None => {
51                    return Result::Err(core::convert::Into::into(
52                        ::derive_builder::UninitializedFieldError::from("collection_name"),
53                    ));
54                }
55            },
56            wait: self.wait.unwrap_or_default(),
57            field_name: match self.field_name {
58                Some(value) => value,
59                None => {
60                    return Result::Err(core::convert::Into::into(
61                        ::derive_builder::UninitializedFieldError::from("field_name"),
62                    ));
63                }
64            },
65            ordering: self.ordering.unwrap_or_default(),
66        })
67    }
68    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
69    fn create_empty() -> Self {
70        Self {
71            collection_name: core::default::Default::default(),
72            wait: core::default::Default::default(),
73            field_name: core::default::Default::default(),
74            ordering: core::default::Default::default(),
75        }
76    }
77}
78
79impl From<DeleteFieldIndexCollectionBuilder> for DeleteFieldIndexCollection {
80    fn from(value: DeleteFieldIndexCollectionBuilder) -> Self {
81        value.build_inner().unwrap_or_else(|_| {
82            panic!(
83                "Failed to convert {0} to {1}",
84                "DeleteFieldIndexCollectionBuilder", "DeleteFieldIndexCollection"
85            )
86        })
87    }
88}
89
90impl DeleteFieldIndexCollectionBuilder {
91    /// Builds the desired type. Can often be omitted.
92    pub fn build(self) -> DeleteFieldIndexCollection {
93        self.build_inner().unwrap_or_else(|_| {
94            panic!(
95                "Failed to build {0} into {1}",
96                "DeleteFieldIndexCollectionBuilder", "DeleteFieldIndexCollection"
97            )
98        })
99    }
100}
101
102impl DeleteFieldIndexCollectionBuilder {
103    pub(crate) fn empty() -> Self {
104        Self::create_empty()
105    }
106}
107
108/// Error type for DeleteFieldIndexCollectionBuilder
109#[non_exhaustive]
110#[derive(Debug)]
111pub enum DeleteFieldIndexCollectionBuilderError {
112    /// Uninitialized field
113    UninitializedField(&'static str),
114    /// Custom validation error
115    ValidationError(String),
116}
117
118// Implementing the Display trait for better error messages
119impl std::fmt::Display for DeleteFieldIndexCollectionBuilderError {
120    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
121        match self {
122            Self::UninitializedField(field) => {
123                write!(f, "`{}` must be initialized", field)
124            }
125            Self::ValidationError(error) => write!(f, "{}", error),
126        }
127    }
128}
129
130// Implementing the Error trait
131impl std::error::Error for DeleteFieldIndexCollectionBuilderError {}
132
133// Implementing From trait for conversion from UninitializedFieldError
134impl From<derive_builder::UninitializedFieldError> for DeleteFieldIndexCollectionBuilderError {
135    fn from(error: derive_builder::UninitializedFieldError) -> Self {
136        Self::UninitializedField(error.field_name())
137    }
138}
139
140// Implementing From trait for conversion from String
141impl From<String> for DeleteFieldIndexCollectionBuilderError {
142    fn from(error: String) -> Self {
143        Self::ValidationError(error)
144    }
145}