qdrant_client/builders/
float_index_params_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct FloatIndexParamsBuilder {
5    /// If true - store index on disk.
6    pub(crate) on_disk: Option<Option<bool>>,
7    /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.
8    pub(crate) is_principal: Option<Option<bool>>,
9}
10
11impl Default for FloatIndexParamsBuilder {
12    fn default() -> Self {
13        Self::new()
14    }
15}
16
17impl FloatIndexParamsBuilder {
18    pub fn new() -> Self {
19        Self::create_empty()
20    }
21
22    /// If true - store index on disk.
23    pub fn on_disk(self, value: bool) -> Self {
24        let mut new = self;
25        new.on_disk = Option::Some(Option::Some(value));
26        new
27    }
28    /// If true - use this key to organize storage of the collection data. This option assumes that this key will be used in majority of filtered requests.
29    pub fn is_principal(self, value: bool) -> Self {
30        let mut new = self;
31        new.is_principal = Option::Some(Option::Some(value));
32        new
33    }
34
35    fn build_inner(self) -> Result<FloatIndexParams, std::convert::Infallible> {
36        Ok(FloatIndexParams {
37            on_disk: self.on_disk.unwrap_or_default(),
38            is_principal: self.is_principal.unwrap_or_default(),
39        })
40    }
41    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
42    fn create_empty() -> Self {
43        Self {
44            on_disk: core::default::Default::default(),
45            is_principal: core::default::Default::default(),
46        }
47    }
48}
49
50impl From<FloatIndexParamsBuilder> for FloatIndexParams {
51    fn from(value: FloatIndexParamsBuilder) -> Self {
52        value.build_inner().unwrap_or_else(|_| {
53            panic!(
54                "Failed to convert {0} to {1}",
55                "FloatIndexParamsBuilder", "FloatIndexParams"
56            )
57        })
58    }
59}
60
61impl FloatIndexParamsBuilder {
62    /// Builds the desired type. Can often be omitted.
63    pub fn build(self) -> FloatIndexParams {
64        self.build_inner().unwrap_or_else(|_| {
65            panic!(
66                "Failed to build {0} into {1}",
67                "FloatIndexParamsBuilder", "FloatIndexParams"
68            )
69        })
70    }
71}