qdrant_client/builders/
context_example_pair_builder.rs

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