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    pub fn replication_factor(self, value: u32) -> Self {
19        let mut new = self;
20        new.replication_factor = Option::Some(Option::Some(value));
21        new
22    }
23    /// How many replicas should apply the operation for us to consider it successful
24    pub fn write_consistency_factor(self, value: u32) -> Self {
25        let mut new = self;
26        new.write_consistency_factor = Option::Some(Option::Some(value));
27        new
28    }
29    /// If true - point's payload will not be stored in memory
30    pub fn on_disk_payload(self, value: bool) -> Self {
31        let mut new = self;
32        new.on_disk_payload = Option::Some(Option::Some(value));
33        new
34    }
35    /// Fan-out every read request to these many additional remote nodes (and return first available response)
36    pub fn read_fan_out_factor(self, value: u32) -> Self {
37        let mut new = self;
38        new.read_fan_out_factor = Option::Some(Option::Some(value));
39        new
40    }
41
42    fn build_inner(self) -> Result<CollectionParamsDiff, std::convert::Infallible> {
43        Ok(CollectionParamsDiff {
44            replication_factor: match self.replication_factor {
45                Some(value) => value,
46                None => core::default::Default::default(),
47            },
48            write_consistency_factor: match self.write_consistency_factor {
49                Some(value) => value,
50                None => core::default::Default::default(),
51            },
52            on_disk_payload: match self.on_disk_payload {
53                Some(value) => value,
54                None => core::default::Default::default(),
55            },
56            read_fan_out_factor: match self.read_fan_out_factor {
57                Some(value) => value,
58                None => core::default::Default::default(),
59            },
60        })
61    }
62    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
63    fn create_empty() -> Self {
64        Self {
65            replication_factor: core::default::Default::default(),
66            write_consistency_factor: core::default::Default::default(),
67            on_disk_payload: core::default::Default::default(),
68            read_fan_out_factor: core::default::Default::default(),
69        }
70    }
71}
72
73impl From<CollectionParamsDiffBuilder> for CollectionParamsDiff {
74    fn from(value: CollectionParamsDiffBuilder) -> Self {
75        value.build_inner().unwrap_or_else(|_| {
76            panic!(
77                "Failed to convert {0} to {1}",
78                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
79            )
80        })
81    }
82}
83
84impl CollectionParamsDiffBuilder {
85    /// Builds the desired type. Can often be omitted.
86    pub fn build(self) -> CollectionParamsDiff {
87        self.build_inner().unwrap_or_else(|_| {
88            panic!(
89                "Failed to build {0} into {1}",
90                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
91            )
92        })
93    }
94}
95
96impl Default for CollectionParamsDiffBuilder {
97    fn default() -> Self {
98        Self::create_empty()
99    }
100}