Skip to main content

qdrant_client/builders/
idf_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct IdfParamsBuilder {
6    /// Filter defining the corpus IDF statistics are computed over.
7    pub(crate) corpus: Option<Option<Filter>>,
8}
9
10impl Default for IdfParamsBuilder {
11    fn default() -> Self {
12        Self::new()
13    }
14}
15
16impl IdfParamsBuilder {
17    pub fn new() -> Self {
18        Self::create_empty()
19    }
20
21    /// Filter defining the corpus: IDF statistics are computed over the points matching
22    /// this filter. If unset, statistics are collection-wide (global).
23    pub fn corpus<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
24        let mut new = self;
25        new.corpus = Option::Some(Option::Some(value.into()));
26        new
27    }
28
29    fn build_inner(self) -> Result<IdfParams, std::convert::Infallible> {
30        Ok(IdfParams {
31            corpus: self.corpus.unwrap_or_default(),
32        })
33    }
34    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
35    fn create_empty() -> Self {
36        Self {
37            corpus: core::default::Default::default(),
38        }
39    }
40}
41
42impl From<IdfParamsBuilder> for IdfParams {
43    fn from(value: IdfParamsBuilder) -> Self {
44        value.build_inner().unwrap_or_else(|_| {
45            panic!(
46                "Failed to convert {0} to {1}",
47                "IdfParamsBuilder", "IdfParams"
48            )
49        })
50    }
51}
52
53impl IdfParamsBuilder {
54    /// Builds the desired type. Can often be omitted.
55    pub fn build(self) -> IdfParams {
56        self.build_inner().unwrap_or_else(|_| {
57            panic!(
58                "Failed to build {0} into {1}",
59                "IdfParamsBuilder", "IdfParams"
60            )
61        })
62    }
63}