qdrant_client/builders/
context_input_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct ContextInputBuilder {
5    /// Search space will be constrained by these pairs of vectors
6    pub(crate) pairs: Option<Vec<ContextInputPair>>,
7}
8
9impl ContextInputBuilder {
10    /// Search space will be constrained by these pairs of vectors
11    pub fn pairs<VALUE: core::convert::Into<Vec<ContextInputPair>>>(self, value: VALUE) -> Self {
12        let mut new = self;
13        new.pairs = Option::Some(value.into());
14        new
15    }
16
17    fn build_inner(self) -> Result<ContextInput, std::convert::Infallible> {
18        Ok(ContextInput {
19            pairs: self.pairs.unwrap_or_default(),
20        })
21    }
22    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
23    fn create_empty() -> Self {
24        Self {
25            pairs: core::default::Default::default(),
26        }
27    }
28}
29
30impl From<ContextInputBuilder> for ContextInput {
31    fn from(value: ContextInputBuilder) -> Self {
32        value.build_inner().unwrap_or_else(|_| {
33            panic!(
34                "Failed to convert {0} to {1}",
35                "ContextInputBuilder", "ContextInput"
36            )
37        })
38    }
39}
40
41impl ContextInputBuilder {
42    /// Builds the desired type. Can often be omitted.
43    pub fn build(self) -> ContextInput {
44        self.build_inner().unwrap_or_else(|_| {
45            panic!(
46                "Failed to build {0} into {1}",
47                "ContextInputBuilder", "ContextInput"
48            )
49        })
50    }
51}
52
53impl Default for ContextInputBuilder {
54    fn default() -> Self {
55        Self::create_empty()
56    }
57}