qdrant_client/builders/
create_alias_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct CreateAliasBuilder {
5 pub(crate) collection_name: Option<String>,
7 pub(crate) alias_name: Option<String>,
9}
10
11impl CreateAliasBuilder {
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 alias_name(self, value: String) -> Self {
22 let mut new = self;
23 new.alias_name = Option::Some(value);
24 new
25 }
26
27 fn build_inner(self) -> Result<CreateAlias, CreateAliasBuilderError> {
28 Ok(CreateAlias {
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 alias_name: match self.alias_name {
38 Some(value) => value,
39 None => {
40 return Result::Err(core::convert::Into::into(
41 ::derive_builder::UninitializedFieldError::from("alias_name"),
42 ));
43 }
44 },
45 })
46 }
47 fn create_empty() -> Self {
49 Self {
50 collection_name: core::default::Default::default(),
51 alias_name: core::default::Default::default(),
52 }
53 }
54}
55
56impl From<CreateAliasBuilder> for CreateAlias {
57 fn from(value: CreateAliasBuilder) -> Self {
58 value.build_inner().unwrap_or_else(|_| {
59 panic!(
60 "Failed to convert {0} to {1}",
61 "CreateAliasBuilder", "CreateAlias"
62 )
63 })
64 }
65}
66
67impl CreateAliasBuilder {
68 pub fn build(self) -> CreateAlias {
70 self.build_inner().unwrap_or_else(|_| {
71 panic!(
72 "Failed to build {0} into {1}",
73 "CreateAliasBuilder", "CreateAlias"
74 )
75 })
76 }
77}
78
79impl CreateAliasBuilder {
80 pub(crate) fn empty() -> Self {
81 Self::create_empty()
82 }
83}
84
85#[non_exhaustive]
87#[derive(Debug)]
88pub enum CreateAliasBuilderError {
89 UninitializedField(&'static str),
91 ValidationError(String),
93}
94
95impl std::fmt::Display for CreateAliasBuilderError {
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
107impl std::error::Error for CreateAliasBuilderError {}
109
110impl From<derive_builder::UninitializedFieldError> for CreateAliasBuilderError {
112 fn from(error: derive_builder::UninitializedFieldError) -> Self {
113 Self::UninitializedField(error.field_name())
114 }
115}
116
117impl From<String> for CreateAliasBuilderError {
119 fn from(error: String) -> Self {
120 Self::ValidationError(error)
121 }
122}