qdrant_client/builders/
update_collection_cluster_setup_request_builder.rs

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