Skip to main content

qdrant_client/builders/
datetime_index_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct DatetimeIndexParamsBuilder {
6    /// If true - store index on disk.
7    pub(crate) on_disk: Option<Option<bool>>,
8    /// 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.
9    pub(crate) is_principal: Option<Option<bool>>,
10    /// If true - enable HNSW index for this field.
11    pub(crate) enable_hnsw: Option<Option<bool>>,
12    /// Memory placement of the index.
13    pub(crate) memory: Option<Option<i32>>,
14}
15
16impl DatetimeIndexParamsBuilder {
17    /// If true - store index on disk.
18    ///
19    /// Deprecated since 1.19.0, use [`memory`](Self::memory) instead.
20    pub fn on_disk(self, value: bool) -> Self {
21        let mut new = self;
22        new.on_disk = Option::Some(Option::Some(value));
23        new
24    }
25    /// 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.
26    pub fn is_principal(self, value: bool) -> Self {
27        let mut new = self;
28        new.is_principal = Option::Some(Option::Some(value));
29        new
30    }
31    /// If true - enable HNSW index for this field.
32    pub fn enable_hnsw(self, value: bool) -> Self {
33        let mut new = self;
34        new.enable_hnsw = Option::Some(Option::Some(value));
35        new
36    }
37    /// Memory placement of the index.
38    /// Overrides the deprecated `on_disk` flag if both are set.
39    pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
40        let mut new = self;
41        new.memory = Option::Some(Option::Some(value.into()));
42        new
43    }
44
45    #[allow(deprecated)]
46    fn build_inner(self) -> Result<DatetimeIndexParams, std::convert::Infallible> {
47        Ok(DatetimeIndexParams {
48            on_disk: self.on_disk.unwrap_or_default(),
49            is_principal: self.is_principal.unwrap_or_default(),
50            enable_hnsw: self.enable_hnsw.unwrap_or_default(),
51            memory: self.memory.unwrap_or_default(),
52        })
53    }
54    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
55    fn create_empty() -> Self {
56        Self {
57            on_disk: core::default::Default::default(),
58            is_principal: core::default::Default::default(),
59            enable_hnsw: core::default::Default::default(),
60            memory: core::default::Default::default(),
61        }
62    }
63}
64
65impl Default for DatetimeIndexParamsBuilder {
66    fn default() -> Self {
67        Self::create_empty()
68    }
69}
70
71impl From<DatetimeIndexParamsBuilder> for DatetimeIndexParams {
72    fn from(value: DatetimeIndexParamsBuilder) -> Self {
73        value.build_inner().unwrap_or_else(|_| {
74            panic!(
75                "Failed to convert {0} to {1}",
76                "DatetimeIndexParamsBuilder", "DatetimeIndexParams"
77            )
78        })
79    }
80}
81
82impl DatetimeIndexParamsBuilder {
83    /// Builds the desired type. Can often be omitted.
84    pub fn build(self) -> DatetimeIndexParams {
85        self.build_inner().unwrap_or_else(|_| {
86            panic!(
87                "Failed to build {0} into {1}",
88                "DatetimeIndexParamsBuilder", "DatetimeIndexParams"
89            )
90        })
91    }
92}