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}
13
14impl UuidIndexParamsBuilder {
15    /// If true - used for tenant optimization.
16    pub fn is_tenant(self, value: bool) -> Self {
17        let mut new = self;
18        new.is_tenant = Option::Some(Option::Some(value));
19        new
20    }
21    /// If true - store index on disk.
22    pub fn on_disk(self, value: bool) -> Self {
23        let mut new = self;
24        new.on_disk = Option::Some(Option::Some(value));
25        new
26    }
27    /// If true - enable HNSW index for this field.
28    pub fn enable_hnsw(self, value: bool) -> Self {
29        let mut new = self;
30        new.enable_hnsw = Option::Some(Option::Some(value));
31        new
32    }
33
34    fn build_inner(self) -> Result<UuidIndexParams, std::convert::Infallible> {
35        Ok(UuidIndexParams {
36            is_tenant: self.is_tenant.unwrap_or_default(),
37            on_disk: self.on_disk.unwrap_or_default(),
38            enable_hnsw: self.enable_hnsw.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            is_tenant: core::default::Default::default(),
45            on_disk: core::default::Default::default(),
46            enable_hnsw: core::default::Default::default(),
47        }
48    }
49}
50
51impl Default for UuidIndexParamsBuilder {
52    fn default() -> Self {
53        Self::create_empty()
54    }
55}
56
57impl From<UuidIndexParamsBuilder> for UuidIndexParams {
58    fn from(value: UuidIndexParamsBuilder) -> Self {
59        value.build_inner().unwrap_or_else(|_| {
60            panic!(
61                "Failed to convert {0} to {1}",
62                "UuidIndexParamsBuilder", "UuidIndexParams"
63            )
64        })
65    }
66}
67
68impl UuidIndexParamsBuilder {
69    /// Builds the desired type. Can often be omitted.
70    pub fn build(self) -> UuidIndexParams {
71        self.build_inner().unwrap_or_else(|_| {
72            panic!(
73                "Failed to build {0} into {1}",
74                "UuidIndexParamsBuilder", "UuidIndexParams"
75            )
76        })
77    }
78}