qdrant_client/builders/
context_example_pair_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct ContextExamplePairBuilder {
5 pub(crate) positive: Option<Option<VectorExample>>,
6 pub(crate) negative: Option<Option<VectorExample>>,
7}
8
9impl ContextExamplePairBuilder {
10 pub fn positive<VALUE: core::convert::Into<VectorExample>>(self, value: VALUE) -> Self {
11 let mut new = self;
12 new.positive = Option::Some(Option::Some(value.into()));
13 new
14 }
15 pub fn negative<VALUE: core::convert::Into<VectorExample>>(self, value: VALUE) -> Self {
16 let mut new = self;
17 new.negative = Option::Some(Option::Some(value.into()));
18 new
19 }
20
21 fn build_inner(self) -> Result<ContextExamplePair, std::convert::Infallible> {
22 Ok(ContextExamplePair {
23 positive: self.positive.unwrap_or_default(),
24 negative: self.negative.unwrap_or_default(),
25 })
26 }
27 fn create_empty() -> Self {
29 Self {
30 positive: core::default::Default::default(),
31 negative: core::default::Default::default(),
32 }
33 }
34}
35
36impl From<ContextExamplePairBuilder> for ContextExamplePair {
37 fn from(value: ContextExamplePairBuilder) -> Self {
38 value.build_inner().unwrap_or_else(|_| {
39 panic!(
40 "Failed to convert {0} to {1}",
41 "ContextExamplePairBuilder", "ContextExamplePair"
42 )
43 })
44 }
45}
46
47impl ContextExamplePairBuilder {
48 pub fn build(self) -> ContextExamplePair {
50 self.build_inner().unwrap_or_else(|_| {
51 panic!(
52 "Failed to build {0} into {1}",
53 "ContextExamplePairBuilder", "ContextExamplePair"
54 )
55 })
56 }
57}
58
59impl Default for ContextExamplePairBuilder {
60 fn default() -> Self {
61 Self::create_empty()
62 }
63}