qdrant_client/builders/
context_input_builder.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use crate::qdrant::*;

pub struct ContextInputBuilder {
    /// Search space will be constrained by these pairs of vectors
    pub(crate) pairs: Option<Vec<ContextInputPair>>,
}

impl ContextInputBuilder {
    /// Search space will be constrained by these pairs of vectors
    #[allow(unused_mut)]
    pub fn pairs<VALUE: core::convert::Into<Vec<ContextInputPair>>>(self, value: VALUE) -> Self {
        let mut new = self;
        new.pairs = Option::Some(value.into());
        new
    }

    fn build_inner(self) -> Result<ContextInput, std::convert::Infallible> {
        Ok(ContextInput {
            pairs: self.pairs.unwrap_or_default(),
        })
    }
    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
    fn create_empty() -> Self {
        Self {
            pairs: core::default::Default::default(),
        }
    }
}

impl From<ContextInputBuilder> for ContextInput {
    fn from(value: ContextInputBuilder) -> Self {
        value.build_inner().unwrap_or_else(|_| {
            panic!(
                "Failed to convert {0} to {1}",
                "ContextInputBuilder", "ContextInput"
            )
        })
    }
}

impl ContextInputBuilder {
    /// Builds the desired type. Can often be omitted.
    pub fn build(self) -> ContextInput {
        self.build_inner().unwrap_or_else(|_| {
            panic!(
                "Failed to build {0} into {1}",
                "ContextInputBuilder", "ContextInput"
            )
        })
    }
}

impl Default for ContextInputBuilder {
    fn default() -> Self {
        Self::create_empty()
    }
}