qdrant_client/builders/
delete_collection_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct DeleteCollectionBuilder {
5 pub(crate) collection_name: Option<String>,
7 pub(crate) timeout: Option<Option<u64>>,
9}
10
11impl DeleteCollectionBuilder {
12 #[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 #[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
27 fn build_inner(self) -> Result<DeleteCollection, DeleteCollectionBuilderError> {
28 Ok(DeleteCollection {
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 timeout: self.timeout.unwrap_or_default(),
38 })
39 }
40 fn create_empty() -> Self {
42 Self {
43 collection_name: core::default::Default::default(),
44 timeout: core::default::Default::default(),
45 }
46 }
47}
48
49impl From<DeleteCollectionBuilder> for DeleteCollection {
50 fn from(value: DeleteCollectionBuilder) -> Self {
51 value.build_inner().unwrap_or_else(|_| {
52 panic!(
53 "Failed to convert {0} to {1}",
54 "DeleteCollectionBuilder", "DeleteCollection"
55 )
56 })
57 }
58}
59
60impl DeleteCollectionBuilder {
61 pub fn build(self) -> DeleteCollection {
63 self.build_inner().unwrap_or_else(|_| {
64 panic!(
65 "Failed to build {0} into {1}",
66 "DeleteCollectionBuilder", "DeleteCollection"
67 )
68 })
69 }
70}
71
72impl DeleteCollectionBuilder {
73 pub(crate) fn empty() -> Self {
74 Self::create_empty()
75 }
76}
77
78#[non_exhaustive]
80#[derive(Debug)]
81pub enum DeleteCollectionBuilderError {
82 UninitializedField(&'static str),
84 ValidationError(String),
86}
87
88impl std::fmt::Display for DeleteCollectionBuilderError {
90 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
91 match self {
92 Self::UninitializedField(field) => {
93 write!(f, "`{field}` must be initialized")
94 }
95 Self::ValidationError(error) => write!(f, "{error}"),
96 }
97 }
98}
99
100impl std::error::Error for DeleteCollectionBuilderError {}
102
103impl From<derive_builder::UninitializedFieldError> for DeleteCollectionBuilderError {
105 fn from(error: derive_builder::UninitializedFieldError) -> Self {
106 Self::UninitializedField(error.field_name())
107 }
108}
109
110impl From<String> for DeleteCollectionBuilderError {
112 fn from(error: String) -> Self {
113 Self::ValidationError(error)
114 }
115}