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 pub fn collection(self, value: String) -> Self {
17 let mut new = self;
18 new.collection = Option::Some(value);
19 new
20 }
21 pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
23 self,
24 value: VALUE,
25 ) -> Self {
26 let mut new = self;
27 new.with_payload = Option::Some(value.into());
28 new
29 }
30 pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
32 self,
33 value: VALUE,
34 ) -> Self {
35 let mut new = self;
36 new.with_vectors = Option::Some(value.into());
37 new
38 }
39
40 fn build_inner(self) -> Result<WithLookup, WithLookupBuilderError> {
41 Ok(WithLookup {
42 collection: match self.collection {
43 Some(value) => value,
44 None => {
45 return Result::Err(core::convert::Into::into(
46 ::derive_builder::UninitializedFieldError::from("collection"),
47 ));
48 }
49 },
50 with_payload: { convert_option(&self.with_payload) },
51 with_vectors: { convert_option(&self.with_vectors) },
52 })
53 }
54 fn create_empty() -> Self {
56 Self {
57 collection: core::default::Default::default(),
58 with_payload: core::default::Default::default(),
59 with_vectors: core::default::Default::default(),
60 }
61 }
62}
63
64impl From<WithLookupBuilder> for WithLookup {
65 fn from(value: WithLookupBuilder) -> Self {
66 value.build_inner().unwrap_or_else(|_| {
67 panic!(
68 "Failed to convert {0} to {1}",
69 "WithLookupBuilder", "WithLookup"
70 )
71 })
72 }
73}
74
75impl WithLookupBuilder {
76 pub fn build(self) -> WithLookup {
78 self.build_inner().unwrap_or_else(|_| {
79 panic!(
80 "Failed to build {0} into {1}",
81 "WithLookupBuilder", "WithLookup"
82 )
83 })
84 }
85}
86
87impl WithLookupBuilder {
88 pub(crate) fn empty() -> Self {
89 Self::create_empty()
90 }
91}
92
93#[non_exhaustive]
94#[derive(Debug)]
95pub enum WithLookupBuilderError {
96 UninitializedField(&'static str),
98 ValidationError(String),
100}
101
102impl std::fmt::Display for WithLookupBuilderError {
104 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
105 match self {
106 Self::UninitializedField(field) => {
107 write!(f, "`{field}` must be initialized")
108 }
109 Self::ValidationError(error) => write!(f, "{error}"),
110 }
111 }
112}
113
114impl std::error::Error for WithLookupBuilderError {}
116
117impl From<derive_builder::UninitializedFieldError> for WithLookupBuilderError {
119 fn from(error: derive_builder::UninitializedFieldError) -> Self {
120 Self::UninitializedField(error.field_name())
121 }
122}
123
124impl From<String> for WithLookupBuilderError {
126 fn from(error: String) -> Self {
127 Self::ValidationError(error)
128 }
129}