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 pub fn collection_name(self, value: String) -> Self {
29 let mut new = self;
30 new.collection_name = Option::Some(value);
31 new
32 }
33 pub fn filter<VALUE: core::convert::Into<Filter>>(self, value: VALUE) -> Self {
35 let mut new = self;
36 new.filter = Option::Some(Option::Some(value.into()));
37 new
38 }
39 pub fn offset<VALUE: core::convert::Into<PointId>>(self, value: VALUE) -> Self {
41 let mut new = self;
42 new.offset = Option::Some(Option::Some(value.into()));
43 new
44 }
45 pub fn limit(self, value: u32) -> Self {
47 let mut new = self;
48 new.limit = Option::Some(Option::Some(value));
49 new
50 }
51 pub fn with_payload<VALUE: core::convert::Into<with_payload_selector::SelectorOptions>>(
53 self,
54 value: VALUE,
55 ) -> Self {
56 let mut new = self;
57 new.with_payload = Option::Some(value.into());
58 new
59 }
60 pub fn with_vectors<VALUE: core::convert::Into<with_vectors_selector::SelectorOptions>>(
62 self,
63 value: VALUE,
64 ) -> Self {
65 let mut new = self;
66 new.with_vectors = Option::Some(value.into());
67 new
68 }
69 pub fn read_consistency<VALUE: core::convert::Into<read_consistency::Value>>(
71 self,
72 value: VALUE,
73 ) -> Self {
74 let mut new = self;
75 new.read_consistency = Option::Some(value.into());
76 new
77 }
78 pub fn shard_key_selector<VALUE: core::convert::Into<ShardKeySelector>>(
80 self,
81 value: VALUE,
82 ) -> Self {
83 let mut new = self;
84 new.shard_key_selector = Option::Some(Option::Some(value.into()));
85 new
86 }
87 pub fn order_by<VALUE: core::convert::Into<OrderBy>>(self, value: VALUE) -> Self {
89 let mut new = self;
90 new.order_by = Option::Some(Option::Some(value.into()));
91 new
92 }
93 pub fn timeout(self, value: u64) -> Self {
95 let mut new = self;
96 new.timeout = Option::Some(Option::Some(value));
97 new
98 }
99
100 fn build_inner(self) -> Result<ScrollPoints, ScrollPointsBuilderError> {
101 Ok(ScrollPoints {
102 collection_name: match self.collection_name {
103 Some(value) => value,
104 None => {
105 return Result::Err(core::convert::Into::into(
106 ::derive_builder::UninitializedFieldError::from("collection_name"),
107 ));
108 }
109 },
110 filter: self.filter.unwrap_or_default(),
111 offset: self.offset.unwrap_or_default(),
112 limit: self.limit.unwrap_or_default(),
113 with_payload: { convert_option(&self.with_payload) },
114 with_vectors: { convert_option(&self.with_vectors) },
115 read_consistency: { convert_option(&self.read_consistency) },
116 shard_key_selector: self.shard_key_selector.unwrap_or_default(),
117 order_by: self.order_by.unwrap_or_default(),
118 timeout: self.timeout.unwrap_or_default(),
119 })
120 }
121 fn create_empty() -> Self {
123 Self {
124 collection_name: core::default::Default::default(),
125 filter: core::default::Default::default(),
126 offset: core::default::Default::default(),
127 limit: core::default::Default::default(),
128 with_payload: core::default::Default::default(),
129 with_vectors: core::default::Default::default(),
130 read_consistency: core::default::Default::default(),
131 shard_key_selector: core::default::Default::default(),
132 order_by: core::default::Default::default(),
133 timeout: core::default::Default::default(),
134 }
135 }
136}
137
138impl From<ScrollPointsBuilder> for ScrollPoints {
139 fn from(value: ScrollPointsBuilder) -> Self {
140 value.build_inner().unwrap_or_else(|_| {
141 panic!(
142 "Failed to convert {0} to {1}",
143 "ScrollPointsBuilder", "ScrollPoints"
144 )
145 })
146 }
147}
148
149impl ScrollPointsBuilder {
150 pub fn build(self) -> ScrollPoints {
152 self.build_inner().unwrap_or_else(|_| {
153 panic!(
154 "Failed to build {0} into {1}",
155 "ScrollPointsBuilder", "ScrollPoints"
156 )
157 })
158 }
159}
160
161impl ScrollPointsBuilder {
162 pub(crate) fn empty() -> Self {
163 Self::create_empty()
164 }
165}
166
167#[non_exhaustive]
168#[derive(Debug)]
169pub enum ScrollPointsBuilderError {
170 UninitializedField(&'static str),
172 ValidationError(String),
174}
175
176impl std::fmt::Display for ScrollPointsBuilderError {
178 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
179 match self {
180 Self::UninitializedField(field) => {
181 write!(f, "`{field}` must be initialized")
182 }
183 Self::ValidationError(error) => write!(f, "{error}"),
184 }
185 }
186}
187
188impl std::error::Error for ScrollPointsBuilderError {}
190
191impl From<derive_builder::UninitializedFieldError> for ScrollPointsBuilderError {
193 fn from(error: derive_builder::UninitializedFieldError) -> Self {
194 Self::UninitializedField(error.field_name())
195 }
196}
197
198impl From<String> for ScrollPointsBuilderError {
200 fn from(error: String) -> Self {
201 Self::ValidationError(error)
202 }
203}