qdrant_client/builders/
context_example_pair_builder.rs

1use 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    #[allow(unused_mut)]
11    pub fn positive<VALUE: core::convert::Into<VectorExample>>(self, value: VALUE) -> Self {
12        let mut new = self;
13        new.positive = Option::Some(Option::Some(value.into()));
14        new
15    }
16    #[allow(unused_mut)]
17    pub fn negative<VALUE: core::convert::Into<VectorExample>>(self, value: VALUE) -> Self {
18        let mut new = self;
19        new.negative = Option::Some(Option::Some(value.into()));
20        new
21    }
22
23    fn build_inner(self) -> Result<ContextExamplePair, std::convert::Infallible> {
24        Ok(ContextExamplePair {
25            positive: self.positive.unwrap_or_default(),
26            negative: self.negative.unwrap_or_default(),
27        })
28    }
29    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
30    fn create_empty() -> Self {
31        Self {
32            positive: core::default::Default::default(),
33            negative: core::default::Default::default(),
34        }
35    }
36}
37
38impl From<ContextExamplePairBuilder> for ContextExamplePair {
39    fn from(value: ContextExamplePairBuilder) -> Self {
40        value.build_inner().unwrap_or_else(|_| {
41            panic!(
42                "Failed to convert {0} to {1}",
43                "ContextExamplePairBuilder", "ContextExamplePair"
44            )
45        })
46    }
47}
48
49impl ContextExamplePairBuilder {
50    /// Builds the desired type. Can often be omitted.
51    pub fn build(self) -> ContextExamplePair {
52        self.build_inner().unwrap_or_else(|_| {
53            panic!(
54                "Failed to build {0} into {1}",
55                "ContextExamplePairBuilder", "ContextExamplePair"
56            )
57        })
58    }
59}
60
61impl Default for ContextExamplePairBuilder {
62    fn default() -> Self {
63        Self::create_empty()
64    }
65}