qdrant_client/builders/
integer_index_params_builder.rs1use crate::qdrant::*;
2
3pub struct IntegerIndexParamsBuilder {
4 pub(crate) lookup: Option<Option<bool>>,
6 pub(crate) range: Option<Option<bool>>,
8 pub(crate) is_principal: Option<Option<bool>>,
10 pub(crate) on_disk: Option<Option<bool>>,
12}
13
14impl IntegerIndexParamsBuilder {
15 pub fn new(lookup: bool, range: bool) -> Self {
16 Self::create_empty().lookup(lookup).range(range)
17 }
18
19 #[allow(unused_mut)]
21 pub fn lookup<VALUE: core::convert::Into<bool>>(self, value: VALUE) -> Self {
22 let mut new = self;
23 new.lookup = Option::Some(Option::Some(value.into()));
24 new
25 }
26 #[allow(unused_mut)]
28 pub fn range<VALUE: core::convert::Into<bool>>(self, value: VALUE) -> Self {
29 let mut new = self;
30 new.range = Option::Some(Option::Some(value.into()));
31 new
32 }
33 #[allow(unused_mut)]
35 pub fn is_principal(self, value: bool) -> Self {
36 let mut new = self;
37 new.is_principal = Option::Some(Option::Some(value));
38 new
39 }
40 #[allow(unused_mut)]
42 pub fn on_disk(self, value: bool) -> Self {
43 let mut new = self;
44 new.on_disk = Option::Some(Option::Some(value));
45 new
46 }
47
48 fn build_inner(self) -> Result<IntegerIndexParams, IntegerIndexParamsBuilderError> {
49 Ok(IntegerIndexParams {
50 lookup: self.lookup.unwrap_or_default(),
51 range: self.range.unwrap_or_default(),
52 is_principal: self.is_principal.unwrap_or_default(),
53 on_disk: self.on_disk.unwrap_or_default(),
54 })
55 }
56 fn create_empty() -> Self {
58 Self {
59 lookup: core::default::Default::default(),
60 range: core::default::Default::default(),
61 is_principal: core::default::Default::default(),
62 on_disk: core::default::Default::default(),
63 }
64 }
65}
66
67impl From<IntegerIndexParamsBuilder> for IntegerIndexParams {
68 fn from(value: IntegerIndexParamsBuilder) -> Self {
69 value.build_inner().unwrap_or_else(|_| {
70 panic!(
71 "Failed to convert {0} to {1}",
72 "IntegerIndexParamsBuilder", "IntegerIndexParams"
73 )
74 })
75 }
76}
77
78impl IntegerIndexParamsBuilder {
79 pub fn build(self) -> IntegerIndexParams {
81 self.build_inner().unwrap_or_else(|_| {
82 panic!(
83 "Failed to build {0} into {1}",
84 "IntegerIndexParamsBuilder", "IntegerIndexParams"
85 )
86 })
87 }
88}
89
90impl Default for IntegerIndexParamsBuilder {
91 fn default() -> Self {
92 Self::create_empty()
93 }
94}
95
96#[non_exhaustive]
98#[derive(Debug)]
99pub enum IntegerIndexParamsBuilderError {
100 UninitializedField(&'static str),
102 ValidationError(String),
104}
105
106impl std::fmt::Display for IntegerIndexParamsBuilderError {
108 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
109 match self {
110 Self::UninitializedField(field) => {
111 write!(f, "`{}` must be initialized", field)
112 }
113 Self::ValidationError(error) => write!(f, "{}", error),
114 }
115 }
116}
117
118impl std::error::Error for IntegerIndexParamsBuilderError {}
120
121impl From<derive_builder::UninitializedFieldError> for IntegerIndexParamsBuilderError {
123 fn from(error: derive_builder::UninitializedFieldError) -> Self {
124 Self::UninitializedField(error.field_name())
125 }
126}
127
128impl From<String> for IntegerIndexParamsBuilderError {
130 fn from(error: String) -> Self {
131 Self::ValidationError(error)
132 }
133}