qdrant_client/builders/
delete_collection_builder.rs1use crate::qdrant::*;
2
3pub struct DeleteCollectionBuilder {
4 pub(crate) collection_name: Option<String>,
6 pub(crate) timeout: Option<Option<u64>>,
8}
9
10impl DeleteCollectionBuilder {
11 #[allow(unused_mut)]
13 pub fn collection_name(self, value: String) -> Self {
14 let mut new = self;
15 new.collection_name = Option::Some(value);
16 new
17 }
18 #[allow(unused_mut)]
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
26 fn build_inner(self) -> Result<DeleteCollection, DeleteCollectionBuilderError> {
27 Ok(DeleteCollection {
28 collection_name: match self.collection_name {
29 Some(value) => value,
30 None => {
31 return Result::Err(core::convert::Into::into(
32 ::derive_builder::UninitializedFieldError::from("collection_name"),
33 ));
34 }
35 },
36 timeout: self.timeout.unwrap_or_default(),
37 })
38 }
39 fn create_empty() -> Self {
41 Self {
42 collection_name: core::default::Default::default(),
43 timeout: core::default::Default::default(),
44 }
45 }
46}
47
48impl From<DeleteCollectionBuilder> for DeleteCollection {
49 fn from(value: DeleteCollectionBuilder) -> Self {
50 value.build_inner().unwrap_or_else(|_| {
51 panic!(
52 "Failed to convert {0} to {1}",
53 "DeleteCollectionBuilder", "DeleteCollection"
54 )
55 })
56 }
57}
58
59impl DeleteCollectionBuilder {
60 pub fn build(self) -> DeleteCollection {
62 self.build_inner().unwrap_or_else(|_| {
63 panic!(
64 "Failed to build {0} into {1}",
65 "DeleteCollectionBuilder", "DeleteCollection"
66 )
67 })
68 }
69}
70
71impl DeleteCollectionBuilder {
72 pub(crate) fn empty() -> Self {
73 Self::create_empty()
74 }
75}
76
77#[non_exhaustive]
79#[derive(Debug)]
80pub enum DeleteCollectionBuilderError {
81 UninitializedField(&'static str),
83 ValidationError(String),
85}
86
87impl std::fmt::Display for DeleteCollectionBuilderError {
89 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
90 match self {
91 Self::UninitializedField(field) => {
92 write!(f, "`{}` must be initialized", field)
93 }
94 Self::ValidationError(error) => write!(f, "{}", error),
95 }
96 }
97}
98
99impl std::error::Error for DeleteCollectionBuilderError {}
101
102impl From<derive_builder::UninitializedFieldError> for DeleteCollectionBuilderError {
104 fn from(error: derive_builder::UninitializedFieldError) -> Self {
105 Self::UninitializedField(error.field_name())
106 }
107}
108
109impl From<String> for DeleteCollectionBuilderError {
111 fn from(error: String) -> Self {
112 Self::ValidationError(error)
113 }
114}