qdrant_client/builders/
update_collection_cluster_setup_request_builder.rs

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