qdrant_client/builders/
delete_field_index_collection_builder.rs

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