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}
15
16impl Default for FloatIndexParamsBuilder {
17 fn default() -> Self {
18 Self::new()
19 }
20}
21
22impl FloatIndexParamsBuilder {
23 pub fn new() -> Self {
24 Self::create_empty()
25 }
26
27 pub fn on_disk(self, value: bool) -> Self {
31 let mut new = self;
32 new.on_disk = Option::Some(Option::Some(value));
33 new
34 }
35 pub fn is_principal(self, value: bool) -> Self {
37 let mut new = self;
38 new.is_principal = Option::Some(Option::Some(value));
39 new
40 }
41 pub fn enable_hnsw(self, value: bool) -> Self {
43 let mut new = self;
44 new.enable_hnsw = Option::Some(Option::Some(value));
45 new
46 }
47 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
50 let mut new = self;
51 new.memory = Option::Some(Option::Some(value.into()));
52 new
53 }
54
55 #[allow(deprecated)]
56 fn build_inner(self) -> Result<FloatIndexParams, std::convert::Infallible> {
57 Ok(FloatIndexParams {
58 on_disk: self.on_disk.unwrap_or_default(),
59 is_principal: self.is_principal.unwrap_or_default(),
60 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
61 memory: self.memory.unwrap_or_default(),
62 })
63 }
64 fn create_empty() -> Self {
66 Self {
67 on_disk: core::default::Default::default(),
68 is_principal: core::default::Default::default(),
69 enable_hnsw: core::default::Default::default(),
70 memory: core::default::Default::default(),
71 }
72 }
73}
74
75impl From<FloatIndexParamsBuilder> for FloatIndexParams {
76 fn from(value: FloatIndexParamsBuilder) -> Self {
77 value.build_inner().unwrap_or_else(|_| {
78 panic!(
79 "Failed to convert {0} to {1}",
80 "FloatIndexParamsBuilder", "FloatIndexParams"
81 )
82 })
83 }
84}
85
86impl FloatIndexParamsBuilder {
87 pub fn build(self) -> FloatIndexParams {
89 self.build_inner().unwrap_or_else(|_| {
90 panic!(
91 "Failed to build {0} into {1}",
92 "FloatIndexParamsBuilder", "FloatIndexParams"
93 )
94 })
95 }
96}