qdrant_client/builders/
clear_payload_points_builder.rs

1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct ClearPayloadPointsBuilder {
6    /// name of the collection
7    pub(crate) collection_name: Option<String>,
8    /// Wait until the changes have been applied?
9    pub(crate) wait: Option<Option<bool>>,
10    /// Affected points
11    points: Option<points_selector::PointsSelectorOneOf>,
12    /// Write ordering guarantees
13    pub(crate) ordering: Option<Option<WriteOrdering>>,
14    /// Option for custom sharding to specify used shard keys
15    pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
16}
17
18impl ClearPayloadPointsBuilder {
19    /// name of the collection
20    #[allow(unused_mut)]
21    pub fn collection_name(self, value: String) -> Self {
22        let mut new = self;
23        new.collection_name = Option::Some(value);
24        new
25    }
26    /// Wait until the changes have been applied?
27    #[allow(unused_mut)]
28    pub fn wait(self, value: bool) -> Self {
29        let mut new = self;
30        new.wait = Option::Some(Option::Some(value));
31        new
32    }
33    /// Affected points
34    #[allow(unused_mut)]
35    pub fn points<VALUE: core::convert::Into<points_selector::PointsSelectorOneOf>>(
36        self,
37        value: VALUE,
38    ) -> Self {
39        let mut new = self;
40        new.points = Option::Some(value.into());
41        new
42    }
43    /// Write ordering guarantees
44    #[allow(unused_mut)]
45    pub fn ordering<VALUE: core::convert::Into<WriteOrdering>>(self, value: VALUE) -> Self {
46        let mut new = self;
47        new.ordering = Option::Some(Option::Some(value.into()));
48        new
49    }
50    /// Option for custom sharding to specify used shard keys
51    #[allow(unused_mut)]
52    pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
53        self,
54        value: VALUE,
55    ) -> Self {
56        let mut new = self;
57        new.shard_key_selector = Option::Some(Option::Some(value.into()));
58        new
59    }
60
61    fn build_inner(self) -> Result<ClearPayloadPoints, ClearPayloadPointsBuilderError> {
62        Ok(ClearPayloadPoints {
63            collection_name: match self.collection_name {
64                Some(value) => value,
65                None => {
66                    return Result::Err(core::convert::Into::into(
67                        ::derive_builder::UninitializedFieldError::from("collection_name"),
68                    ));
69                }
70            },
71            wait: self.wait.unwrap_or_default(),
72            points: { convert_option(&self.points) },
73            ordering: self.ordering.unwrap_or_default(),
74            shard_key_selector: self.shard_key_selector.unwrap_or_default(),
75        })
76    }
77    /// Create an empty builder, with all fields set to `None` or `PhantomData`.
78    fn create_empty() -> Self {
79        Self {
80            collection_name: core::default::Default::default(),
81            wait: core::default::Default::default(),
82            points: core::default::Default::default(),
83            ordering: core::default::Default::default(),
84            shard_key_selector: core::default::Default::default(),
85        }
86    }
87}
88
89impl From<ClearPayloadPointsBuilder> for ClearPayloadPoints {
90    fn from(value: ClearPayloadPointsBuilder) -> Self {
91        value.build_inner().unwrap_or_else(|_| {
92            panic!(
93                "Failed to convert {0} to {1}",
94                "ClearPayloadPointsBuilder", "ClearPayloadPoints"
95            )
96        })
97    }
98}
99
100impl ClearPayloadPointsBuilder {
101    /// Builds the desired type. Can often be omitted.
102    pub fn build(self) -> ClearPayloadPoints {
103        self.build_inner().unwrap_or_else(|_| {
104            panic!(
105                "Failed to build {0} into {1}",
106                "ClearPayloadPointsBuilder", "ClearPayloadPoints"
107            )
108        })
109    }
110}
111
112impl ClearPayloadPointsBuilder {
113    pub(crate) fn empty() -> Self {
114        Self::create_empty()
115    }
116}
117/// Error type for ClearPayloadPointsBuilder
118#[non_exhaustive]
119#[derive(Debug)]
120pub enum ClearPayloadPointsBuilderError {
121    /// Uninitialized field
122    UninitializedField(&'static str),
123    /// Custom validation error
124    ValidationError(String),
125}
126
127impl std::fmt::Display for ClearPayloadPointsBuilderError {
128    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
129        match self {
130            Self::UninitializedField(field) => {
131                write!(f, "`{field}` must be initialized")
132            }
133            Self::ValidationError(error) => write!(f, "{error}"),
134        }
135    }
136}
137
138impl std::error::Error for ClearPayloadPointsBuilderError {}
139
140impl From<derive_builder::UninitializedFieldError> for ClearPayloadPointsBuilderError {
141    fn from(error: derive_builder::UninitializedFieldError) -> Self {
142        Self::UninitializedField(error.field_name())
143    }
144}
145
146impl From<String> for ClearPayloadPointsBuilderError {
147    fn from(error: String) -> Self {
148        Self::ValidationError(error)
149    }
150}