qdrant_client/builders/
bool_index_params_builder.rs1use crate::qdrant::*;
2
3#[must_use]
4#[derive(Clone)]
5pub struct BoolIndexParamsBuilder {
6 pub(crate) on_disk: Option<Option<bool>>,
8 pub(crate) enable_hnsw: Option<Option<bool>>,
10 pub(crate) memory: Option<Option<i32>>,
12 pub(crate) nested: Option<Option<String>>,
14}
15
16impl Default for BoolIndexParamsBuilder {
17 fn default() -> Self {
18 Self::new()
19 }
20}
21
22impl BoolIndexParamsBuilder {
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 enable_hnsw(self, value: bool) -> Self {
37 let mut new = self;
38 new.enable_hnsw = Option::Some(Option::Some(value));
39 new
40 }
41 pub fn memory<VALUE: core::convert::Into<i32>>(self, value: VALUE) -> Self {
44 let mut new = self;
45 new.memory = Option::Some(Option::Some(value.into()));
46 new
47 }
48 pub fn nested(self, value: impl Into<String>) -> Self {
51 let mut new = self;
52 new.nested = Option::Some(Option::Some(value.into()));
53 new
54 }
55
56 #[allow(deprecated)]
57 fn build_inner(self) -> Result<BoolIndexParams, std::convert::Infallible> {
58 Ok(BoolIndexParams {
59 on_disk: self.on_disk.unwrap_or_default(),
60 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
61 memory: self.memory.unwrap_or_default(),
62 nested: self.nested.unwrap_or_default(),
63 })
64 }
65 fn create_empty() -> Self {
67 Self {
68 on_disk: core::default::Default::default(),
69 enable_hnsw: core::default::Default::default(),
70 memory: core::default::Default::default(),
71 nested: core::default::Default::default(),
72 }
73 }
74}
75
76impl From<BoolIndexParamsBuilder> for BoolIndexParams {
77 fn from(value: BoolIndexParamsBuilder) -> Self {
78 value.build_inner().unwrap_or_else(|_| {
79 panic!(
80 "Failed to convert {0} to {1}",
81 "BoolIndexParamsBuilder", "BoolIndexParams"
82 )
83 })
84 }
85}
86
87impl BoolIndexParamsBuilder {
88 pub fn build(self) -> BoolIndexParams {
90 self.build_inner().unwrap_or_else(|_| {
91 panic!(
92 "Failed to build {0} into {1}",
93 "BoolIndexParamsBuilder", "BoolIndexParams"
94 )
95 })
96 }
97}