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