qdrant_client/builders/
recommend_batch_points_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct RecommendBatchPointsBuilder {
6 pub(crate) collection_name: Option<String>,
8 pub(crate) recommend_points: Option<Vec<RecommendPoints>>,
9 read_consistency: Option<read_consistency::Value>,
11 pub(crate) timeout: Option<Option<u64>>,
13}
14
15impl RecommendBatchPointsBuilder {
16 #[allow(unused_mut)]
18 pub fn collection_name(self, value: String) -> Self {
19 let mut new = self;
20 new.collection_name = Option::Some(value);
21 new
22 }
23 #[allow(unused_mut)]
24 pub fn recommend_points(self, value: Vec<RecommendPoints>) -> Self {
25 let mut new = self;
26 new.recommend_points = Option::Some(value);
27 new
28 }
29 #[allow(unused_mut)]
31 pub fn read_consistency<VALUE: core::convert::Into<read_consistency::Value>>(
32 self,
33 value: VALUE,
34 ) -> Self {
35 let mut new = self;
36 new.read_consistency = Option::Some(value.into());
37 new
38 }
39 #[allow(unused_mut)]
41 pub fn timeout(self, value: u64) -> Self {
42 let mut new = self;
43 new.timeout = Option::Some(Option::Some(value));
44 new
45 }
46
47 fn build_inner(self) -> Result<RecommendBatchPoints, RecommendBatchPointsBuilderError> {
48 Ok(RecommendBatchPoints {
49 collection_name: match self.collection_name {
50 Some(value) => value,
51 None => {
52 return Result::Err(core::convert::Into::into(
53 ::derive_builder::UninitializedFieldError::from("collection_name"),
54 ));
55 }
56 },
57 recommend_points: match self.recommend_points {
58 Some(value) => value,
59 None => {
60 return Result::Err(core::convert::Into::into(
61 ::derive_builder::UninitializedFieldError::from("recommend_points"),
62 ));
63 }
64 },
65 read_consistency: { convert_option(&self.read_consistency) },
66 timeout: self.timeout.unwrap_or_default(),
67 })
68 }
69 fn create_empty() -> Self {
71 Self {
72 collection_name: core::default::Default::default(),
73 recommend_points: core::default::Default::default(),
74 read_consistency: core::default::Default::default(),
75 timeout: core::default::Default::default(),
76 }
77 }
78}
79
80impl From<RecommendBatchPointsBuilder> for RecommendBatchPoints {
81 fn from(value: RecommendBatchPointsBuilder) -> Self {
82 value.build_inner().unwrap_or_else(|_| {
83 panic!(
84 "Failed to convert {0} to {1}",
85 "RecommendBatchPointsBuilder", "RecommendBatchPoints"
86 )
87 })
88 }
89}
90
91impl RecommendBatchPointsBuilder {
92 pub fn build(self) -> RecommendBatchPoints {
94 self.build_inner().unwrap_or_else(|_| {
95 panic!(
96 "Failed to build {0} into {1}",
97 "RecommendBatchPointsBuilder", "RecommendBatchPoints"
98 )
99 })
100 }
101}
102
103impl RecommendBatchPointsBuilder {
104 pub(crate) fn empty() -> Self {
105 Self::create_empty()
106 }
107}
108
109#[non_exhaustive]
111#[derive(Debug)]
112pub enum RecommendBatchPointsBuilderError {
113 UninitializedField(&'static str),
115 ValidationError(String),
117}
118
119impl std::fmt::Display for RecommendBatchPointsBuilderError {
121 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
122 match self {
123 Self::UninitializedField(field) => {
124 write!(f, "`{field}` must be initialized")
125 }
126 Self::ValidationError(error) => write!(f, "{error}"),
127 }
128 }
129}
130
131impl std::error::Error for RecommendBatchPointsBuilderError {}
133
134impl From<derive_builder::UninitializedFieldError> for RecommendBatchPointsBuilderError {
136 fn from(error: derive_builder::UninitializedFieldError) -> Self {
137 Self::UninitializedField(error.field_name())
138 }
139}
140
141impl From<String> for RecommendBatchPointsBuilderError {
143 fn from(error: String) -> Self {
144 Self::ValidationError(error)
145 }
146}