qdrant_client/builders/
with_lookup_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct WithLookupBuilder {
6 pub(crate) collection: Option<String>,
8 with_payload: Option<with_payload_selector::SelectorOptions>,
10 with_vectors: Option<with_vectors_selector::SelectorOptions>,
12}
13
14impl WithLookupBuilder {
15 #[allow(unused_mut)]
17 pub fn collection(self, value: String) -> Self {
18 let mut new = self;
19 new.collection = Option::Some(value);
20 new
21 }
22 #[allow(unused_mut)]
24 pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
25 self,
26 value: VALUE,
27 ) -> Self {
28 let mut new = self;
29 new.with_payload = Option::Some(value.into());
30 new
31 }
32 #[allow(unused_mut)]
34 pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
35 self,
36 value: VALUE,
37 ) -> Self {
38 let mut new = self;
39 new.with_vectors = Option::Some(value.into());
40 new
41 }
42
43 fn build_inner(self) -> Result<WithLookup, WithLookupBuilderError> {
44 Ok(WithLookup {
45 collection: match self.collection {
46 Some(value) => value,
47 None => {
48 return Result::Err(core::convert::Into::into(
49 ::derive_builder::UninitializedFieldError::from("collection"),
50 ));
51 }
52 },
53 with_payload: { convert_option(&self.with_payload) },
54 with_vectors: { convert_option(&self.with_vectors) },
55 })
56 }
57 fn create_empty() -> Self {
59 Self {
60 collection: core::default::Default::default(),
61 with_payload: core::default::Default::default(),
62 with_vectors: core::default::Default::default(),
63 }
64 }
65}
66
67impl From<WithLookupBuilder> for WithLookup {
68 fn from(value: WithLookupBuilder) -> Self {
69 value.build_inner().unwrap_or_else(|_| {
70 panic!(
71 "Failed to convert {0} to {1}",
72 "WithLookupBuilder", "WithLookup"
73 )
74 })
75 }
76}
77
78impl WithLookupBuilder {
79 pub fn build(self) -> WithLookup {
81 self.build_inner().unwrap_or_else(|_| {
82 panic!(
83 "Failed to build {0} into {1}",
84 "WithLookupBuilder", "WithLookup"
85 )
86 })
87 }
88}
89
90impl WithLookupBuilder {
91 pub(crate) fn empty() -> Self {
92 Self::create_empty()
93 }
94}
95
96#[non_exhaustive]
97#[derive(Debug)]
98pub enum WithLookupBuilderError {
99 UninitializedField(&'static str),
101 ValidationError(String),
103}
104
105impl std::fmt::Display for WithLookupBuilderError {
107 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
108 match self {
109 Self::UninitializedField(field) => {
110 write!(f, "`{field}` must be initialized")
111 }
112 Self::ValidationError(error) => write!(f, "{error}"),
113 }
114 }
115}
116
117impl std::error::Error for WithLookupBuilderError {}
119
120impl From<derive_builder::UninitializedFieldError> for WithLookupBuilderError {
122 fn from(error: derive_builder::UninitializedFieldError) -> Self {
123 Self::UninitializedField(error.field_name())
124 }
125}
126
127impl From<String> for WithLookupBuilderError {
129 fn from(error: String) -> Self {
130 Self::ValidationError(error)
131 }
132}