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