qdrant_client/builders/
delete_snapshot_request_builder.rs

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