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