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