Skip to main content

qdrant_client/builders/
collection_params_diff_builder.rs

1use crate::qdrant::*;
2
3#[derive(Clone)]
4pub struct CollectionParamsDiffBuilder {
5    /// Number of replicas of each shard that network tries to maintain
6    pub(crate) replication_factor: Option<Option<u32>>,
7    /// How many replicas should apply the operation for us to consider it successful
8    pub(crate) write_consistency_factor: Option<Option<u32>>,
9    /// If true - point's payload will not be stored in memory
10    pub(crate) on_disk_payload: Option<Option<bool>>,
11    /// Fan-out every read request to these many additional remote nodes (and return first available response)
12    pub(crate) read_fan_out_factor: Option<Option<u32>>,
13    /// Fan-out delay in milliseconds. If set, the fan-out request will be delayed by this amount.
14    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    /// Number of replicas of each shard that network tries to maintain
20    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    /// How many replicas should apply the operation for us to consider it successful
26    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    /// If true - point's payload will not be stored in memory
32    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    /// Fan-out every read request to these many additional remote nodes (and return first available response)
38    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    /// Fan-out delay in milliseconds. If set, the fan-out request will be delayed by this amount.
44    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    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
75    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    /// Builds the desired type. Can often be omitted.
99    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}