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 pub fn collection_name(self, value: String) -> Self {
14 let mut new = self;
15 new.collection_name = Option::Some(value);
16 new
17 }
18 pub fn timeout(self, value: u64) -> Self {
20 let mut new = self;
21 new.timeout = Option::Some(Option::Some(value));
22 new
23 }
24
25 fn build_inner(self) -> Result<DeleteCollection, DeleteCollectionBuilderError> {
26 Ok(DeleteCollection {
27 collection_name: match self.collection_name {
28 Some(value) => value,
29 None => {
30 return Result::Err(core::convert::Into::into(
31 ::derive_builder::UninitializedFieldError::from("collection_name"),
32 ));
33 }
34 },
35 timeout: self.timeout.unwrap_or_default(),
36 })
37 }
38 fn create_empty() -> Self {
40 Self {
41 collection_name: core::default::Default::default(),
42 timeout: core::default::Default::default(),
43 }
44 }
45}
46
47impl From<DeleteCollectionBuilder> for DeleteCollection {
48 fn from(value: DeleteCollectionBuilder) -> Self {
49 value.build_inner().unwrap_or_else(|_| {
50 panic!(
51 "Failed to convert {0} to {1}",
52 "DeleteCollectionBuilder", "DeleteCollection"
53 )
54 })
55 }
56}
57
58impl DeleteCollectionBuilder {
59 pub fn build(self) -> DeleteCollection {
61 self.build_inner().unwrap_or_else(|_| {
62 panic!(
63 "Failed to build {0} into {1}",
64 "DeleteCollectionBuilder", "DeleteCollection"
65 )
66 })
67 }
68}
69
70impl DeleteCollectionBuilder {
71 pub(crate) fn empty() -> Self {
72 Self::create_empty()
73 }
74}
75
76#[non_exhaustive]
78#[derive(Debug)]
79pub enum DeleteCollectionBuilderError {
80 UninitializedField(&'static str),
82 ValidationError(String),
84}
85
86impl std::fmt::Display for DeleteCollectionBuilderError {
88 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
89 match self {
90 Self::UninitializedField(field) => {
91 write!(f, "`{field}` must be initialized")
92 }
93 Self::ValidationError(error) => write!(f, "{error}"),
94 }
95 }
96}
97
98impl std::error::Error for DeleteCollectionBuilderError {}
100
101impl From<derive_builder::UninitializedFieldError> for DeleteCollectionBuilderError {
103 fn from(error: derive_builder::UninitializedFieldError) -> Self {
104 Self::UninitializedField(error.field_name())
105 }
106}
107
108impl From<String> for DeleteCollectionBuilderError {
110 fn from(error: String) -> Self {
111 Self::ValidationError(error)
112 }
113}