qdrant_client/builders/
collection_params_diff_builder.rs1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct CollectionParamsDiffBuilder {
5 pub(crate) replication_factor: Option<Option<u32>>,
7 pub(crate) write_consistency_factor: Option<Option<u32>>,
9 pub(crate) on_disk_payload: Option<Option<bool>>,
11 pub(crate) read_fan_out_factor: Option<Option<u32>>,
13 pub(crate) read_fan_out_delay_ms: Option<Option<u64>>,
15}
16#[allow(clippy::all)]
17#[allow(clippy::derive_partial_eq_without_eq)]
18impl CollectionParamsDiffBuilder {
19 pub fn replication_factor(self, value: u32) -> Self {
21 let mut new = self;
22 new.replication_factor = Option::Some(Option::Some(value));
23 new
24 }
25 pub fn write_consistency_factor(self, value: u32) -> Self {
27 let mut new = self;
28 new.write_consistency_factor = Option::Some(Option::Some(value));
29 new
30 }
31 pub fn on_disk_payload(self, value: bool) -> Self {
33 let mut new = self;
34 new.on_disk_payload = Option::Some(Option::Some(value));
35 new
36 }
37 pub fn read_fan_out_factor(self, value: u32) -> Self {
39 let mut new = self;
40 new.read_fan_out_factor = Option::Some(Option::Some(value));
41 new
42 }
43 pub fn read_fan_out_delay_ms(self, value: u64) -> Self {
45 let mut new = self;
46 new.read_fan_out_delay_ms = Option::Some(Option::Some(value));
47 new
48 }
49
50 fn build_inner(self) -> Result<CollectionParamsDiff, std::convert::Infallible> {
51 Ok(CollectionParamsDiff {
52 replication_factor: match self.replication_factor {
53 Some(value) => value,
54 None => core::default::Default::default(),
55 },
56 write_consistency_factor: match self.write_consistency_factor {
57 Some(value) => value,
58 None => core::default::Default::default(),
59 },
60 on_disk_payload: match self.on_disk_payload {
61 Some(value) => value,
62 None => core::default::Default::default(),
63 },
64 read_fan_out_factor: match self.read_fan_out_factor {
65 Some(value) => value,
66 None => core::default::Default::default(),
67 },
68 read_fan_out_delay_ms: match self.read_fan_out_delay_ms {
69 Some(value) => value,
70 None => core::default::Default::default(),
71 },
72 })
73 }
74 fn create_empty() -> Self {
76 Self {
77 replication_factor: core::default::Default::default(),
78 write_consistency_factor: core::default::Default::default(),
79 on_disk_payload: core::default::Default::default(),
80 read_fan_out_factor: core::default::Default::default(),
81 read_fan_out_delay_ms: core::default::Default::default(),
82 }
83 }
84}
85
86impl From<CollectionParamsDiffBuilder> for CollectionParamsDiff {
87 fn from(value: CollectionParamsDiffBuilder) -> Self {
88 value.build_inner().unwrap_or_else(|_| {
89 panic!(
90 "Failed to convert {0} to {1}",
91 "CollectionParamsDiffBuilder", "CollectionParamsDiff"
92 )
93 })
94 }
95}
96
97impl CollectionParamsDiffBuilder {
98 pub fn build(self) -> CollectionParamsDiff {
100 self.build_inner().unwrap_or_else(|_| {
101 panic!(
102 "Failed to build {0} into {1}",
103 "CollectionParamsDiffBuilder", "CollectionParamsDiff"
104 )
105 })
106 }
107}
108
109impl Default for CollectionParamsDiffBuilder {
110 fn default() -> Self {
111 Self::create_empty()
112 }
113}