qdrant_client/builders/
create_vector_name_request_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[must_use]
5#[derive(Clone)]
6pub struct CreateVectorNameRequestBuilder {
7 pub(crate) collection_name: Option<String>,
9 pub(crate) wait: Option<Option<bool>>,
11 pub(crate) vector_name: Option<String>,
13 vector_config: Option<create_vector_name_request::VectorConfig>,
15 pub(crate) timeout: Option<Option<u64>>,
17 pub(crate) ordering: Option<Option<WriteOrdering>>,
19}
20
21impl CreateVectorNameRequestBuilder {
22 pub fn collection_name(self, value: impl Into<String>) -> Self {
24 let mut new = self;
25 new.collection_name = Option::Some(value.into());
26 new
27 }
28
29 pub fn wait(self, value: bool) -> Self {
31 let mut new = self;
32 new.wait = Option::Some(Option::Some(value));
33 new
34 }
35
36 pub fn vector_name(self, value: impl Into<String>) -> Self {
38 let mut new = self;
39 new.vector_name = Option::Some(value.into());
40 new
41 }
42
43 pub fn vector_config<VALUE: core::convert::Into<create_vector_name_request::VectorConfig>>(
48 self,
49 value: VALUE,
50 ) -> Self {
51 let mut new = self;
52 new.vector_config = Option::Some(value.into());
53 new
54 }
55
56 pub fn timeout(self, value: u64) -> Self {
58 let mut new = self;
59 new.timeout = Option::Some(Option::Some(value));
60 new
61 }
62
63 pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
65 let mut new = self;
66 new.ordering = Option::Some(Option::Some(value.into()));
67 new
68 }
69
70 fn build_inner(self) -> Result<CreateVectorNameRequest, CreateVectorNameRequestBuilderError> {
71 Ok(CreateVectorNameRequest {
72 collection_name: match self.collection_name {
73 Some(value) => value,
74 None => {
75 return Result::Err(core::convert::Into::into(
76 ::derive_builder::UninitializedFieldError::from("collection_name"),
77 ));
78 }
79 },
80 wait: self.wait.unwrap_or_default(),
81 vector_name: match self.vector_name {
82 Some(value) => value,
83 None => {
84 return Result::Err(core::convert::Into::into(
85 ::derive_builder::UninitializedFieldError::from("vector_name"),
86 ));
87 }
88 },
89 timeout: self.timeout.unwrap_or_default(),
90 ordering: self.ordering.unwrap_or_default(),
91 vector_config: { convert_option(&self.vector_config) },
92 })
93 }
94 fn create_empty() -> Self {
96 Self {
97 collection_name: core::default::Default::default(),
98 wait: core::default::Default::default(),
99 vector_name: core::default::Default::default(),
100 vector_config: core::default::Default::default(),
101 timeout: core::default::Default::default(),
102 ordering: core::default::Default::default(),
103 }
104 }
105}
106
107impl From<CreateVectorNameRequestBuilder> for CreateVectorNameRequest {
108 fn from(value: CreateVectorNameRequestBuilder) -> Self {
109 value.build_inner().unwrap_or_else(|_| {
110 panic!(
111 "Failed to convert {0} to {1}",
112 "CreateVectorNameRequestBuilder", "CreateVectorNameRequest"
113 )
114 })
115 }
116}
117
118impl CreateVectorNameRequestBuilder {
119 pub fn build(self) -> CreateVectorNameRequest {
121 self.build_inner().unwrap_or_else(|_| {
122 panic!(
123 "Failed to build {0} into {1}",
124 "CreateVectorNameRequestBuilder", "CreateVectorNameRequest"
125 )
126 })
127 }
128}
129
130impl CreateVectorNameRequestBuilder {
131 pub(crate) fn empty() -> Self {
132 Self::create_empty()
133 }
134}
135
136#[non_exhaustive]
138#[derive(Debug)]
139pub enum CreateVectorNameRequestBuilderError {
140 UninitializedField(&'static str),
142 ValidationError(String),
144}
145
146impl std::fmt::Display for CreateVectorNameRequestBuilderError {
148 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
149 match self {
150 Self::UninitializedField(field) => {
151 write!(f, "`{field}` must be initialized")
152 }
153 Self::ValidationError(error) => write!(f, "{error}"),
154 }
155 }
156}
157
158impl std::error::Error for CreateVectorNameRequestBuilderError {}
160
161impl From<derive_builder::UninitializedFieldError> for CreateVectorNameRequestBuilderError {
163 fn from(error: derive_builder::UninitializedFieldError) -> Self {
164 Self::UninitializedField(error.field_name())
165 }
166}
167
168impl From<String> for CreateVectorNameRequestBuilderError {
170 fn from(error: String) -> Self {
171 Self::ValidationError(error)
172 }
173}