Skip to main content

qdrant_client/builders/
context_input_builder.rs

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