qdrant_client/builders/
float_index_params_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct FloatIndexParamsBuilder {
6 pub(crate) on_disk: Option<Option<bool>>,
8 pub(crate) is_principal: Option<Option<bool>>,
10 pub(crate) enable_hnsw: Option<Option<bool>>,
12 pub(crate) memory: Option<Option<i32>>,
14 pub(crate) nested: Option<Option<String>>,
16}
17
18impl Default for FloatIndexParamsBuilder {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl FloatIndexParamsBuilder {
25 pub fn new() -> Self {
26 Self::create_empty()
27 }
28
29 pub fn on_disk(self, value: bool) -> Self {
33 let mut new = self;
34 new.on_disk = Option::Some(Option::Some(value));
35 new
36 }
37 pub fn is_principal(self, value: bool) -> Self {
39 let mut new = self;
40 new.is_principal = Option::Some(Option::Some(value));
41 new
42 }
43 pub fn enable_hnsw(self, value: bool) -> Self {
45 let mut new = self;
46 new.enable_hnsw = Option::Some(Option::Some(value));
47 new
48 }
49 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
52 let mut new = self;
53 new.memory = Option::Some(Option::Some(value.into()));
54 new
55 }
56 pub fn nested(self, value: impl Into<String>) -> Self {
59 let mut new = self;
60 new.nested = Option::Some(Option::Some(value.into()));
61 new
62 }
63
64 #[allow(deprecated)]
65 fn build_inner(self) -> Result<FloatIndexParams, std::convert::Infallible> {
66 Ok(FloatIndexParams {
67 on_disk: self.on_disk.unwrap_or_default(),
68 is_principal: self.is_principal.unwrap_or_default(),
69 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
70 memory: self.memory.unwrap_or_default(),
71 nested: self.nested.unwrap_or_default(),
72 })
73 }
74 fn create_empty() -> Self {
76 Self {
77 on_disk: core::default::Default::default(),
78 is_principal: core::default::Default::default(),
79 enable_hnsw: core::default::Default::default(),
80 memory: core::default::Default::default(),
81 nested: core::default::Default::default(),
82 }
83 }
84}
85
86impl From<FloatIndexParamsBuilder> for FloatIndexParams {
87 fn from(value: FloatIndexParamsBuilder) -> Self {
88 value.build_inner().unwrap_or_else(|_| {
89 panic!(
90 "Failed to convert {0} to {1}",
91 "FloatIndexParamsBuilder", "FloatIndexParams"
92 )
93 })
94 }
95}
96
97impl FloatIndexParamsBuilder {
98 pub fn build(self) -> FloatIndexParams {
100 self.build_inner().unwrap_or_else(|_| {
101 panic!(
102 "Failed to build {0} into {1}",
103 "FloatIndexParamsBuilder", "FloatIndexParams"
104 )
105 })
106 }
107}