Skip to main content

qdrant_client/builders/
uuid_index_params_builder.rs

1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct UuidIndexParamsBuilder {
6    /// If true - used for tenant optimization.
7    pub(crate) is_tenant: Option<Option<bool>>,
8    /// If true - store index on disk.
9    pub(crate) on_disk: 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 UuidIndexParamsBuilder {
17    /// If true - used for tenant optimization.
18    pub fn is_tenant(self, value: bool) -> Self {
19        let mut new = self;
20        new.is_tenant = Option::Some(Option::Some(value));
21        new
22    }
23    /// If true - store index on disk.
24    ///
25    /// Deprecated since 1.19.0, use [`memory`](Self::memory) instead.
26    pub fn on_disk(self, value: bool) -> Self {
27        let mut new = self;
28        new.on_disk = 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<UuidIndexParams, std::convert::Infallible> {
47        Ok(UuidIndexParams {
48            is_tenant: self.is_tenant.unwrap_or_default(),
49            on_disk: self.on_disk.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            is_tenant: core::default::Default::default(),
58            on_disk: core::default::Default::default(),
59            enable_hnsw: core::default::Default::default(),
60            memory: core::default::Default::default(),
61        }
62    }
63}
64
65impl Default for UuidIndexParamsBuilder {
66    fn default() -> Self {
67        Self::create_empty()
68    }
69}
70
71impl From<UuidIndexParamsBuilder> for UuidIndexParams {
72    fn from(value: UuidIndexParamsBuilder) -> Self {
73        value.build_inner().unwrap_or_else(|_| {
74            panic!(
75                "Failed to convert {0} to {1}",
76                "UuidIndexParamsBuilder", "UuidIndexParams"
77            )
78        })
79    }
80}
81
82impl UuidIndexParamsBuilder {
83    /// Builds the desired type. Can often be omitted.
84    pub fn build(self) -> UuidIndexParams {
85        self.build_inner().unwrap_or_else(|_| {
86            panic!(
87                "Failed to build {0} into {1}",
88                "UuidIndexParamsBuilder", "UuidIndexParams"
89            )
90        })
91    }
92}