qdrant_client/builders/
collection_params_diff_builder.rs

1use crate::qdrant::*;
2
3pub struct CollectionParamsDiffBuilder {
4    /// Number of replicas of each shard that network tries to maintain
5    pub(crate) replication_factor: Option<Option<u32>>,
6    /// How many replicas should apply the operation for us to consider it successful
7    pub(crate) write_consistency_factor: Option<Option<u32>>,
8    /// If true - point's payload will not be stored in memory
9    pub(crate) on_disk_payload: Option<Option<bool>>,
10    /// Fan-out every read request to these many additional remote nodes (and return first available response)
11    pub(crate) read_fan_out_factor: Option<Option<u32>>,
12}
13#[allow(clippy::all)]
14#[allow(clippy::derive_partial_eq_without_eq)]
15impl CollectionParamsDiffBuilder {
16    /// Number of replicas of each shard that network tries to maintain
17    #[allow(unused_mut)]
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    #[allow(unused_mut)]
25    pub fn write_consistency_factor(self, value: u32) -> Self {
26        let mut new = self;
27        new.write_consistency_factor = Option::Some(Option::Some(value));
28        new
29    }
30    /// If true - point's payload will not be stored in memory
31    #[allow(unused_mut)]
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    #[allow(unused_mut)]
39    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
45    fn build_inner(self) -> Result<CollectionParamsDiff, std::convert::Infallible> {
46        Ok(CollectionParamsDiff {
47            replication_factor: match self.replication_factor {
48                Some(value) => value,
49                None => core::default::Default::default(),
50            },
51            write_consistency_factor: match self.write_consistency_factor {
52                Some(value) => value,
53                None => core::default::Default::default(),
54            },
55            on_disk_payload: match self.on_disk_payload {
56                Some(value) => value,
57                None => core::default::Default::default(),
58            },
59            read_fan_out_factor: match self.read_fan_out_factor {
60                Some(value) => value,
61                None => core::default::Default::default(),
62            },
63        })
64    }
65    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
66    fn create_empty() -> Self {
67        Self {
68            replication_factor: core::default::Default::default(),
69            write_consistency_factor: core::default::Default::default(),
70            on_disk_payload: core::default::Default::default(),
71            read_fan_out_factor: core::default::Default::default(),
72        }
73    }
74}
75
76impl From<CollectionParamsDiffBuilder> for CollectionParamsDiff {
77    fn from(value: CollectionParamsDiffBuilder) -> Self {
78        value.build_inner().unwrap_or_else(|_| {
79            panic!(
80                "Failed to convert {0} to {1}",
81                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
82            )
83        })
84    }
85}
86
87impl CollectionParamsDiffBuilder {
88    /// Builds the desired type. Can often be omitted.
89    pub fn build(self) -> CollectionParamsDiff {
90        self.build_inner().unwrap_or_else(|_| {
91            panic!(
92                "Failed to build {0} into {1}",
93                "CollectionParamsDiffBuilder", "CollectionParamsDiff"
94            )
95        })
96    }
97}
98
99impl Default for CollectionParamsDiffBuilder {
100    fn default() -> Self {
101        Self::create_empty()
102    }
103}