qdrant_client/builders/
lookup_location_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct LookupLocationBuilder {
5 pub(crate) collection_name: Option<String>,
6 pub(crate) vector_name: Option<Option<String>>,
8 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
10}
11
12impl LookupLocationBuilder {
13 pub fn collection_name(self, value: String) -> Self {
14 let mut new = self;
15 new.collection_name = Option::Some(value);
16 new
17 }
18 pub fn vector_name<VALUE: core::convert::Into<String>>(self, value: VALUE) -> Self {
20 let mut new = self;
21 new.vector_name = Option::Some(Option::Some(value.into()));
22 new
23 }
24 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
26 self,
27 value: VALUE,
28 ) -> Self {
29 let mut new = self;
30 new.shard_key_selector = Option::Some(Option::Some(value.into()));
31 new
32 }
33
34 fn build_inner(self) -> Result<LookupLocation, LookupLocationBuilderError> {
35 Ok(LookupLocation {
36 collection_name: match self.collection_name {
37 Some(value) => value,
38 None => {
39 return Result::Err(core::convert::Into::into(
40 ::derive_builder::UninitializedFieldError::from("collection_name"),
41 ));
42 }
43 },
44 vector_name: self.vector_name.unwrap_or_default(),
45 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
46 })
47 }
48 fn create_empty() -> Self {
50 Self {
51 collection_name: core::default::Default::default(),
52 vector_name: core::default::Default::default(),
53 shard_key_selector: core::default::Default::default(),
54 }
55 }
56}
57
58impl From<LookupLocationBuilder> for LookupLocation {
59 fn from(value: LookupLocationBuilder) -> Self {
60 value.build_inner().unwrap_or_else(|_| {
61 panic!(
62 "Failed to convert {0} to {1}",
63 "LookupLocationBuilder", "LookupLocation"
64 )
65 })
66 }
67}
68
69impl LookupLocationBuilder {
70 pub fn build(self) -> LookupLocation {
72 self.build_inner().unwrap_or_else(|_| {
73 panic!(
74 "Failed to build {0} into {1}",
75 "LookupLocationBuilder", "LookupLocation"
76 )
77 })
78 }
79}
80
81impl LookupLocationBuilder {
82 pub(crate) fn empty() -> Self {
83 Self::create_empty()
84 }
85}
86
87#[non_exhaustive]
89#[derive(Debug)]
90pub enum LookupLocationBuilderError {
91 UninitializedField(&'static str),
93 ValidationError(String),
95}
96
97impl std::fmt::Display for LookupLocationBuilderError {
99 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
100 match self {
101 Self::UninitializedField(field) => {
102 write!(f, "`{field}` must be initialized")
103 }
104 Self::ValidationError(error) => write!(f, "{error}"),
105 }
106 }
107}
108
109impl std::error::Error for LookupLocationBuilderError {}
111
112impl From<derive_builder::UninitializedFieldError> for LookupLocationBuilderError {
114 fn from(error: derive_builder::UninitializedFieldError) -> Self {
115 Self::UninitializedField(error.field_name())
116 }
117}
118
119impl From<String> for LookupLocationBuilderError {
121 fn from(error: String) -> Self {
122 Self::ValidationError(error)
123 }
124}