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}
14#[allow(clippy::all)]
15#[allow(clippy::derive_partial_eq_without_eq)]
16impl CollectionParamsDiffBuilder {
17    /// Number of replicas of each shard that network tries to maintain
18    #[allow(unused_mut)]
19    pub fn replication_factor(self, value: u32) -> Self {
20        let mut new = self;
21        new.replication_factor = Option::Some(Option::Some(value));
22        new
23    }
24    /// How many replicas should apply the operation for us to consider it successful
25    #[allow(unused_mut)]
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    #[allow(unused_mut)]
33    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    /// Fan-out every read request to these many additional remote nodes (and return first available response)
39    #[allow(unused_mut)]
40    pub fn read_fan_out_factor(self, value: u32) -> Self {
41        let mut new = self;
42        new.read_fan_out_factor = Option::Some(Option::Some(value));
43        new
44    }
45
46    fn build_inner(self) -> Result<CollectionParamsDiff, std::convert::Infallible> {
47        Ok(CollectionParamsDiff {
48            replication_factor: match self.replication_factor {
49                Some(value) => value,
50                None => core::default::Default::default(),
51            },
52            write_consistency_factor: match self.write_consistency_factor {
53                Some(value) => value,
54                None => core::default::Default::default(),
55            },
56            on_disk_payload: match self.on_disk_payload {
57                Some(value) => value,
58                None => core::default::Default::default(),
59            },
60            read_fan_out_factor: match self.read_fan_out_factor {
61                Some(value) => value,
62                None => core::default::Default::default(),
63            },
64        })
65    }
66    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
67    fn create_empty() -> Self {
68        Self {
69            replication_factor: core::default::Default::default(),
70            write_consistency_factor: core::default::Default::default(),
71            on_disk_payload: core::default::Default::default(),
72            read_fan_out_factor: core::default::Default::default(),
73        }
74    }
75}
76
77impl From<CollectionParamsDiffBuilder> for CollectionParamsDiff {
78    fn from(value: CollectionParamsDiffBuilder) -> Self {
79        value.build_inner().unwrap_or_else(|_| {
80            panic!(
81                "Failed to convert {0} to {1}",
82                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
83            )
84        })
85    }
86}
87
88impl CollectionParamsDiffBuilder {
89    /// Builds the desired type. Can often be omitted.
90    pub fn build(self) -> CollectionParamsDiff {
91        self.build_inner().unwrap_or_else(|_| {
92            panic!(
93                "Failed to build {0} into {1}",
94                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
95            )
96        })
97    }
98}
99
100impl Default for CollectionParamsDiffBuilder {
101    fn default() -> Self {
102        Self::create_empty()
103    }
104}