qdrant_client/builders/
discover_input_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct DiscoverInputBuilder {
5 pub(crate) target: Option<Option<VectorInput>>,
7 pub(crate) context: Option<Option<ContextInput>>,
9}
10
11impl DiscoverInputBuilder {
12 pub fn target<VALUE: core::convert::Into<VectorInput>>(self, value: VALUE) -> Self {
14 let mut new = self;
15 new.target = Option::Some(Option::Some(value.into()));
16 new
17 }
18 pub fn context<VALUE: core::convert::Into<ContextInput>>(self, value: VALUE) -> Self {
20 let mut new = self;
21 new.context = Option::Some(Option::Some(value.into()));
22 new
23 }
24
25 fn build_inner(self) -> Result<DiscoverInput, DiscoverInputBuilderError> {
26 Ok(DiscoverInput {
27 target: self.target.unwrap_or_default(),
28 context: self.context.unwrap_or_default(),
29 })
30 }
31 fn create_empty() -> Self {
33 Self {
34 target: core::default::Default::default(),
35 context: core::default::Default::default(),
36 }
37 }
38}
39
40impl From<DiscoverInputBuilder> for DiscoverInput {
41 fn from(value: DiscoverInputBuilder) -> Self {
42 value.build_inner().unwrap_or_else(|_| {
43 panic!(
44 "Failed to convert {0} to {1}",
45 "DiscoverInputBuilder", "DiscoverInput"
46 )
47 })
48 }
49}
50
51impl DiscoverInputBuilder {
52 pub fn build(self) -> DiscoverInput {
54 self.build_inner().unwrap_or_else(|_| {
55 panic!(
56 "Failed to build {0} into {1}",
57 "DiscoverInputBuilder", "DiscoverInput"
58 )
59 })
60 }
61}
62
63impl DiscoverInputBuilder {
64 pub(crate) fn empty() -> Self {
65 Self::create_empty()
66 }
67}
68
69#[non_exhaustive]
71#[derive(Debug)]
72pub enum DiscoverInputBuilderError {
73 UninitializedField(&'static str),
75 ValidationError(String),
77}
78
79impl From<derive_builder::UninitializedFieldError> for DiscoverInputBuilderError {
81 fn from(s: derive_builder::UninitializedFieldError) -> Self {
82 Self::UninitializedField(s.field_name())
83 }
84}
85
86impl From<String> for DiscoverInputBuilderError {
88 fn from(s: String) -> Self {
89 Self::ValidationError(s)
90 }
91}
92
93impl std::fmt::Display for DiscoverInputBuilderError {
95 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
96 match self {
97 Self::UninitializedField(ref field) => {
98 write!(f, "`{field}` must be initialized")
99 }
100 Self::ValidationError(ref error) => write!(f, "{error}"),
101 }
102 }
103}
104
105impl std::error::Error for DiscoverInputBuilderError {}