qdrant_client/builders/
scroll_points_builder.rs1use crate::grpc_macros::convert_option;
2use crate::qdrant::*;
3
4#[derive(Clone)]
5pub struct ScrollPointsBuilder {
6 pub(crate) collection_name: Option<String>,
7 pub(crate) filter: Option<Option<Filter>>,
9 pub(crate) offset: Option<Option<PointId>>,
11 pub(crate) limit: Option<Option<u32>>,
13 with_payload: Option<with_payload_selector::SelectorOptions>,
15 with_vectors: Option<with_vectors_selector::SelectorOptions>,
17 read_consistency: Option<read_consistency::Value>,
19 pub(crate) shard_key_selector: Option<Option<ShardKeySelector>>,
21 pub(crate) order_by: Option<Option<OrderBy>>,
23 pub(crate) timeout: Option<Option<u64>>,
25}
26
27impl ScrollPointsBuilder {
28 #[allow(unused_mut)]
29 pub fn collection_name(self, value: String) -> Self {
30 let mut new = self;
31 new.collection_name = Option::Some(value);
32 new
33 }
34 #[allow(unused_mut)]
36 pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
37 let mut new = self;
38 new.filter = Option::Some(Option::Some(value.into()));
39 new
40 }
41 #[allow(unused_mut)]
43 pub fn offset<VALUE: core::convert::Into<PointId>>(self, value: VALUE) -> Self {
44 let mut new = self;
45 new.offset = Option::Some(Option::Some(value.into()));
46 new
47 }
48 #[allow(unused_mut)]
50 pub fn limit(self, value: u32) -> Self {
51 let mut new = self;
52 new.limit = Option::Some(Option::Some(value));
53 new
54 }
55 #[allow(unused_mut)]
57 pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
58 self,
59 value: VALUE,
60 ) -> Self {
61 let mut new = self;
62 new.with_payload = Option::Some(value.into());
63 new
64 }
65 #[allow(unused_mut)]
67 pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
68 self,
69 value: VALUE,
70 ) -> Self {
71 let mut new = self;
72 new.with_vectors = Option::Some(value.into());
73 new
74 }
75 #[allow(unused_mut)]
77 pub fn read_consistency<VALUE: core::convert::Into<read_consistency::Value>>(
78 self,
79 value: VALUE,
80 ) -> Self {
81 let mut new = self;
82 new.read_consistency = Option::Some(value.into());
83 new
84 }
85 #[allow(unused_mut)]
87 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
88 self,
89 value: VALUE,
90 ) -> Self {
91 let mut new = self;
92 new.shard_key_selector = Option::Some(Option::Some(value.into()));
93 new
94 }
95 #[allow(unused_mut)]
97 pub fn order_by<VALUE: core::convert::Into<OrderBy>>(self, value: VALUE) -> Self {
98 let mut new = self;
99 new.order_by = Option::Some(Option::Some(value.into()));
100 new
101 }
102 #[allow(unused_mut)]
104 pub fn timeout(self, value: u64) -> Self {
105 let mut new = self;
106 new.timeout = Option::Some(Option::Some(value));
107 new
108 }
109
110 fn build_inner(self) -> Result<ScrollPoints, ScrollPointsBuilderError> {
111 Ok(ScrollPoints {
112 collection_name: match self.collection_name {
113 Some(value) => value,
114 None => {
115 return Result::Err(core::convert::Into::into(
116 ::derive_builder::UninitializedFieldError::from("collection_name"),
117 ));
118 }
119 },
120 filter: self.filter.unwrap_or_default(),
121 offset: self.offset.unwrap_or_default(),
122 limit: self.limit.unwrap_or_default(),
123 with_payload: { convert_option(&self.with_payload) },
124 with_vectors: { convert_option(&self.with_vectors) },
125 read_consistency: { convert_option(&self.read_consistency) },
126 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
127 order_by: self.order_by.unwrap_or_default(),
128 timeout: self.timeout.unwrap_or_default(),
129 })
130 }
131 fn create_empty() -> Self {
133 Self {
134 collection_name: core::default::Default::default(),
135 filter: core::default::Default::default(),
136 offset: core::default::Default::default(),
137 limit: core::default::Default::default(),
138 with_payload: core::default::Default::default(),
139 with_vectors: core::default::Default::default(),
140 read_consistency: core::default::Default::default(),
141 shard_key_selector: core::default::Default::default(),
142 order_by: core::default::Default::default(),
143 timeout: core::default::Default::default(),
144 }
145 }
146}
147
148impl From<ScrollPointsBuilder> for ScrollPoints {
149 fn from(value: ScrollPointsBuilder) -> Self {
150 value.build_inner().unwrap_or_else(|_| {
151 panic!(
152 "Failed to convert {0} to {1}",
153 "ScrollPointsBuilder", "ScrollPoints"
154 )
155 })
156 }
157}
158
159impl ScrollPointsBuilder {
160 pub fn build(self) -> ScrollPoints {
162 self.build_inner().unwrap_or_else(|_| {
163 panic!(
164 "Failed to build {0} into {1}",
165 "ScrollPointsBuilder", "ScrollPoints"
166 )
167 })
168 }
169}
170
171impl ScrollPointsBuilder {
172 pub(crate) fn empty() -> Self {
173 Self::create_empty()
174 }
175}
176
177#[non_exhaustive]
178#[derive(Debug)]
179pub enum ScrollPointsBuilderError {
180 UninitializedField(&'static str),
182 ValidationError(String),
184}
185
186impl std::fmt::Display for ScrollPointsBuilderError {
188 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
189 match self {
190 Self::UninitializedField(field) => {
191 write!(f, "`{field}` must be initialized")
192 }
193 Self::ValidationError(error) => write!(f, "{error}"),
194 }
195 }
196}
197
198impl std::error::Error for ScrollPointsBuilderError {}
200
201impl From<derive_builder::UninitializedFieldError> for ScrollPointsBuilderError {
203 fn from(error: derive_builder::UninitializedFieldError) -> Self {
204 Self::UninitializedField(error.field_name())
205 }
206}
207
208impl From<String> for ScrollPointsBuilderError {
210 fn from(error: String) -> Self {
211 Self::ValidationError(error)
212 }
213}