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}
11
12impl Default for BoolIndexParamsBuilder {
13 fn default() -> Self {
14 Self::new()
15 }
16}
17
18impl BoolIndexParamsBuilder {
19 pub fn new() -> Self {
20 Self::create_empty()
21 }
22
23 pub fn on_disk(self, value: bool) -> Self {
25 let mut new = self;
26 new.on_disk = Option::Some(Option::Some(value));
27 new
28 }
29 pub fn enable_hnsw(self, value: bool) -> Self {
31 let mut new = self;
32 new.enable_hnsw = Option::Some(Option::Some(value));
33 new
34 }
35
36 fn build_inner(self) -> Result<BoolIndexParams, std::convert::Infallible> {
37 Ok(BoolIndexParams {
38 on_disk: self.on_disk.unwrap_or_default(),
39 enable_hnsw: self.enable_hnsw.unwrap_or_default(),
40 })
41 }
42 fn create_empty() -> Self {
44 Self {
45 on_disk: core::default::Default::default(),
46 enable_hnsw: core::default::Default::default(),
47 }
48 }
49}
50
51impl From<BoolIndexParamsBuilder> for BoolIndexParams {
52 fn from(value: BoolIndexParamsBuilder) -> Self {
53 value.build_inner().unwrap_or_else(|_| {
54 panic!(
55 "Failed to convert {0} to {1}",
56 "BoolIndexParamsBuilder", "BoolIndexParams"
57 )
58 })
59 }
60}
61
62impl BoolIndexParamsBuilder {
63 pub fn build(self) -> BoolIndexParams {
65 self.build_inner().unwrap_or_else(|_| {
66 panic!(
67 "Failed to build {0} into {1}",
68 "BoolIndexParamsBuilder", "BoolIndexParams"
69 )
70 })
71 }
72}