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 #[allow(unused_mut)]
14 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 #[allow(unused_mut)]
21 pub fn context<VALUE: core::convert::Into<ContextInput>>(self, value: VALUE) -> Self {
22 let mut new = self;
23 new.context = Option::Some(Option::Some(value.into()));
24 new
25 }
26
27 fn build_inner(self) -> Result<DiscoverInput, DiscoverInputBuilderError> {
28 Ok(DiscoverInput {
29 target: self.target.unwrap_or_default(),
30 context: self.context.unwrap_or_default(),
31 })
32 }
33 fn create_empty() -> Self {
35 Self {
36 target: core::default::Default::default(),
37 context: core::default::Default::default(),
38 }
39 }
40}
41
42impl From<DiscoverInputBuilder> for DiscoverInput {
43 fn from(value: DiscoverInputBuilder) -> Self {
44 value.build_inner().unwrap_or_else(|_| {
45 panic!(
46 "Failed to convert {0} to {1}",
47 "DiscoverInputBuilder", "DiscoverInput"
48 )
49 })
50 }
51}
52
53impl DiscoverInputBuilder {
54 pub fn build(self) -> DiscoverInput {
56 self.build_inner().unwrap_or_else(|_| {
57 panic!(
58 "Failed to build {0} into {1}",
59 "DiscoverInputBuilder", "DiscoverInput"
60 )
61 })
62 }
63}
64
65impl DiscoverInputBuilder {
66 pub(crate) fn empty() -> Self {
67 Self::create_empty()
68 }
69}
70
71#[non_exhaustive]
73#[derive(Debug)]
74pub enum DiscoverInputBuilderError {
75 UninitializedField(&'static str),
77 ValidationError(String),
79}
80
81impl From<derive_builder::UninitializedFieldError> for DiscoverInputBuilderError {
83 fn from(s: derive_builder::UninitializedFieldError) -> Self {
84 Self::UninitializedField(s.field_name())
85 }
86}
87
88impl From<String> for DiscoverInputBuilderError {
90 fn from(s: String) -> Self {
91 Self::ValidationError(s)
92 }
93}
94
95impl std::fmt::Display for DiscoverInputBuilderError {
97 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
98 match self {
99 Self::UninitializedField(ref field) => {
100 write!(f, "`{field}` must be initialized")
101 }
102 Self::ValidationError(ref error) => write!(f, "{error}"),
103 }
104 }
105}
106
107impl std::error::Error for DiscoverInputBuilderError {}