qdrant_client/grpc_conversions/
mod.rs1mod extensions;
2mod primitives;
3
4use crate::client::Payload;
5use crate::qdrant::point_id::PointIdOptions;
6use crate::qdrant::points_selector::PointsSelectorOneOf;
7use crate::qdrant::value::Kind;
8use crate::qdrant::{
9 alias_operations, condition, group_id, points_update_operation, quantization_config,
10 quantization_config_diff, r#match, read_consistency, shard_key, start_from, target_vector,
11 update_collection_cluster_setup_request, vector_example, vectors_config, vectors_config_diff,
12 with_payload_selector, with_vectors_selector, AbortShardTransfer, AbortShardTransferBuilder,
13 AliasOperations, BinaryQuantization, BinaryQuantizationBuilder, Condition, CreateAlias,
14 CreateShardKey, DeleteAlias, DeleteShardKey, Disabled, FieldCondition, Filter, GeoLineString,
15 GeoPoint, GroupId, HasIdCondition, IsEmptyCondition, IsNullCondition, ListValue, Match,
16 MoveShard, MoveShardBuilder, NestedCondition, PayloadExcludeSelector, PayloadIncludeSelector,
17 PointId, PointsIdsList, PointsSelector, PointsUpdateOperation, ProductQuantization,
18 ProductQuantizationBuilder, QuantizationConfig, QuantizationConfigDiff, ReadConsistency,
19 RenameAlias, Replica, ReplicateShard, ReplicateShardBuilder, RestartTransfer,
20 ScalarQuantization, ScalarQuantizationBuilder, ShardKey, ShardKeySelector, SparseIndexConfig,
21 SparseVectorParams, StartFrom, Struct, TargetVector, Value, Vector, VectorExample,
22 VectorParams, VectorParamsBuilder, VectorParamsDiff, VectorParamsDiffBuilder,
23 VectorParamsDiffMap, VectorParamsMap, VectorsConfig, VectorsConfigDiff, VectorsSelector,
24 WithPayloadSelector, WithVectorsSelector,
25};
26
27impl From<Vec<PointId>> for PointsSelector {
28 fn from(point_ids: Vec<PointId>) -> Self {
29 PointsSelector {
30 points_selector_one_of: Some(PointsSelectorOneOf::Points(PointsIdsList {
31 ids: point_ids,
32 })),
33 }
34 }
35}
36
37impl<T> From<Vec<T>> for Value
38where
39 T: Into<Value>,
40{
41 fn from(val: Vec<T>) -> Self {
42 Self {
43 kind: Some(Kind::ListValue(ListValue {
44 values: val.into_iter().map(|v| v.into()).collect(),
45 })),
46 }
47 }
48}
49
50impl From<Payload> for Value {
51 fn from(val: Payload) -> Self {
52 Self {
53 kind: Some(Kind::StructValue(Struct { fields: val.0 })),
54 }
55 }
56}
57
58impl From<shard_key::Key> for ShardKey {
59 fn from(key: shard_key::Key) -> Self {
60 ShardKey { key: Some(key) }
61 }
62}
63
64impl From<Vec<shard_key::Key>> for ShardKeySelector {
65 fn from(shard_keys: Vec<shard_key::Key>) -> Self {
66 ShardKeySelector {
67 shard_keys: shard_keys.into_iter().map(ShardKey::from).collect(),
68 }
69 }
70}
71
72impl From<Vec<ShardKey>> for ShardKeySelector {
73 fn from(value: Vec<ShardKey>) -> Self {
74 Self { shard_keys: value }
75 }
76}
77
78impl From<vectors_config::Config> for VectorsConfig {
79 fn from(value: vectors_config::Config) -> Self {
80 VectorsConfig {
81 config: Some(value),
82 }
83 }
84}
85
86impl From<VectorParams> for vectors_config::Config {
87 fn from(value: VectorParams) -> Self {
88 Self::Params(value)
89 }
90}
91
92impl From<VectorParamsMap> for vectors_config::Config {
93 fn from(value: VectorParamsMap) -> Self {
94 Self::ParamsMap(value)
95 }
96}
97
98impl From<vectors_config_diff::Config> for VectorsConfigDiff {
99 fn from(value: vectors_config_diff::Config) -> Self {
100 Self {
101 config: Some(value),
102 }
103 }
104}
105
106impl From<VectorParamsDiff> for vectors_config_diff::Config {
107 fn from(value: VectorParamsDiff) -> Self {
108 Self::Params(value)
109 }
110}
111
112impl From<VectorParamsDiffMap> for vectors_config_diff::Config {
113 fn from(value: VectorParamsDiffMap) -> Self {
114 Self::ParamsMap(value)
115 }
116}
117
118impl From<SparseIndexConfig> for SparseVectorParams {
119 fn from(value: SparseIndexConfig) -> Self {
120 Self {
121 index: Some(value),
122 modifier: None,
123 }
124 }
125}
126
127impl From<quantization_config::Quantization> for QuantizationConfig {
128 fn from(value: quantization_config::Quantization) -> Self {
129 Self {
130 quantization: Some(value),
131 }
132 }
133}
134
135impl From<ScalarQuantization> for quantization_config::Quantization {
136 fn from(value: ScalarQuantization) -> Self {
137 Self::Scalar(value)
138 }
139}
140
141impl From<ProductQuantization> for quantization_config::Quantization {
142 fn from(value: ProductQuantization) -> Self {
143 Self::Product(value)
144 }
145}
146
147impl From<BinaryQuantization> for quantization_config::Quantization {
148 fn from(value: BinaryQuantization) -> Self {
149 Self::Binary(value)
150 }
151}
152
153impl From<quantization_config_diff::Quantization> for QuantizationConfigDiff {
154 fn from(value: quantization_config_diff::Quantization) -> Self {
155 Self {
156 quantization: Some(value),
157 }
158 }
159}
160
161impl From<ScalarQuantization> for quantization_config_diff::Quantization {
162 fn from(value: ScalarQuantization) -> Self {
163 Self::Scalar(value)
164 }
165}
166
167impl From<ProductQuantization> for quantization_config_diff::Quantization {
168 fn from(value: ProductQuantization) -> Self {
169 Self::Product(value)
170 }
171}
172
173impl From<Disabled> for quantization_config_diff::Quantization {
174 fn from(value: Disabled) -> Self {
175 Self::Disabled(value)
176 }
177}
178
179impl From<BinaryQuantization> for quantization_config_diff::Quantization {
180 fn from(value: BinaryQuantization) -> Self {
181 Self::Binary(value)
182 }
183}
184
185impl From<alias_operations::Action> for AliasOperations {
186 fn from(value: alias_operations::Action) -> Self {
187 AliasOperations {
188 action: Some(value),
189 }
190 }
191}
192
193impl From<CreateAlias> for alias_operations::Action {
194 fn from(value: CreateAlias) -> Self {
195 Self::CreateAlias(value)
196 }
197}
198
199impl From<RenameAlias> for alias_operations::Action {
200 fn from(value: RenameAlias) -> Self {
201 Self::RenameAlias(value)
202 }
203}
204
205impl From<DeleteAlias> for alias_operations::Action {
206 fn from(value: DeleteAlias) -> Self {
207 Self::DeleteAlias(value)
208 }
209}
210
211impl From<Kind> for Value {
212 fn from(value: Kind) -> Self {
213 Self { kind: Some(value) }
214 }
215}
216
217impl From<Vec<Value>> for ListValue {
218 fn from(value: Vec<Value>) -> Self {
219 Self { values: value }
220 }
221}
222
223impl From<read_consistency::Value> for ReadConsistency {
224 fn from(value: read_consistency::Value) -> Self {
225 Self { value: Some(value) }
226 }
227}
228
229impl From<PointIdOptions> for PointId {
230 fn from(value: PointIdOptions) -> Self {
231 Self {
232 point_id_options: Some(value),
233 }
234 }
235}
236
237impl From<with_payload_selector::SelectorOptions> for WithPayloadSelector {
238 fn from(value: with_payload_selector::SelectorOptions) -> Self {
239 Self {
240 selector_options: Some(value),
241 }
242 }
243}
244
245impl From<PayloadIncludeSelector> for with_payload_selector::SelectorOptions {
246 fn from(value: PayloadIncludeSelector) -> Self {
247 Self::Include(value)
248 }
249}
250
251impl From<PayloadExcludeSelector> for with_payload_selector::SelectorOptions {
252 fn from(value: PayloadExcludeSelector) -> Self {
253 Self::Exclude(value)
254 }
255}
256
257impl From<with_vectors_selector::SelectorOptions> for WithVectorsSelector {
258 fn from(value: with_vectors_selector::SelectorOptions) -> Self {
259 Self {
260 selector_options: Some(value),
261 }
262 }
263}
264
265impl From<VectorsSelector> for with_vectors_selector::SelectorOptions {
266 fn from(value: VectorsSelector) -> Self {
267 Self::Include(value)
268 }
269}
270
271impl From<start_from::Value> for StartFrom {
272 fn from(value: start_from::Value) -> Self {
273 Self { value: Some(value) }
274 }
275}
276
277impl From<target_vector::Target> for TargetVector {
278 fn from(value: target_vector::Target) -> Self {
279 Self {
280 target: Some(value),
281 }
282 }
283}
284
285impl From<VectorExample> for target_vector::Target {
286 fn from(value: VectorExample) -> Self {
287 Self::Single(value)
288 }
289}
290
291impl From<vector_example::Example> for VectorExample {
292 fn from(value: vector_example::Example) -> Self {
293 Self {
294 example: Some(value),
295 }
296 }
297}
298
299impl From<PointId> for vector_example::Example {
300 fn from(value: PointId) -> Self {
301 Self::Id(value)
302 }
303}
304
305impl From<Vector> for vector_example::Example {
306 fn from(value: Vector) -> Self {
307 Self::Vector(value)
308 }
309}
310
311impl From<points_update_operation::Operation> for PointsUpdateOperation {
312 fn from(value: points_update_operation::Operation) -> Self {
313 Self {
314 operation: Some(value),
315 }
316 }
317}
318
319impl From<group_id::Kind> for GroupId {
320 fn from(value: group_id::Kind) -> Self {
321 Self { kind: Some(value) }
322 }
323}
324
325impl From<condition::ConditionOneOf> for Condition {
326 fn from(value: condition::ConditionOneOf) -> Self {
327 Self {
328 condition_one_of: Some(value),
329 }
330 }
331}
332
333impl From<FieldCondition> for condition::ConditionOneOf {
334 fn from(value: FieldCondition) -> Self {
335 Self::Field(value)
336 }
337}
338
339impl From<IsEmptyCondition> for condition::ConditionOneOf {
340 fn from(value: IsEmptyCondition) -> Self {
341 Self::IsEmpty(value)
342 }
343}
344
345impl From<HasIdCondition> for condition::ConditionOneOf {
346 fn from(value: HasIdCondition) -> Self {
347 Self::HasId(value)
348 }
349}
350
351impl From<Filter> for condition::ConditionOneOf {
352 fn from(value: Filter) -> Self {
353 Self::Filter(value)
354 }
355}
356
357impl From<IsNullCondition> for condition::ConditionOneOf {
358 fn from(value: IsNullCondition) -> Self {
359 Self::IsNull(value)
360 }
361}
362
363impl From<NestedCondition> for condition::ConditionOneOf {
364 fn from(value: NestedCondition) -> Self {
365 Self::Nested(value)
366 }
367}
368
369impl From<Vec<PointId>> for HasIdCondition {
370 fn from(value: Vec<PointId>) -> Self {
371 Self { has_id: value }
372 }
373}
374
375impl From<r#match::MatchValue> for Match {
376 fn from(value: r#match::MatchValue) -> Self {
377 Self {
378 match_value: Some(value),
379 }
380 }
381}
382
383impl From<Vec<GeoPoint>> for GeoLineString {
384 fn from(value: Vec<GeoPoint>) -> Self {
385 Self { points: value }
386 }
387}
388
389impl From<PointsSelectorOneOf> for PointsSelector {
390 fn from(value: PointsSelectorOneOf) -> Self {
391 Self {
392 points_selector_one_of: Some(value),
393 }
394 }
395}
396
397impl From<Filter> for PointsSelectorOneOf {
398 fn from(value: Filter) -> Self {
399 Self::Filter(value)
400 }
401}
402
403impl<I: Into<PointId>, const N: usize> From<[I; N]> for PointsIdsList {
404 fn from(value: [I; N]) -> Self {
405 let ids: Vec<_> = value.into_iter().map(|i| i.into()).collect();
406 Self { ids }
407 }
408}
409
410impl<I: Into<PointId>> From<Vec<I>> for PointsIdsList {
411 fn from(value: Vec<I>) -> Self {
412 let ids: Vec<_> = value.into_iter().map(|i| i.into()).collect();
413 Self { ids }
414 }
415}
416
417impl<I: Into<PointsIdsList>> From<I> for PointsSelectorOneOf {
418 fn from(value: I) -> Self {
419 Self::Points(value.into())
420 }
421}
422
423impl From<VectorParamsDiffBuilder> for vectors_config_diff::Config {
424 fn from(value: VectorParamsDiffBuilder) -> Self {
425 value.build().into()
426 }
427}
428
429impl From<VectorParamsBuilder> for vectors_config::Config {
430 fn from(value: VectorParamsBuilder) -> Self {
431 value.build().into()
432 }
433}
434
435impl From<ScalarQuantizationBuilder> for quantization_config_diff::Quantization {
436 fn from(value: ScalarQuantizationBuilder) -> Self {
437 Self::Scalar(value.build())
438 }
439}
440
441impl From<ProductQuantizationBuilder> for quantization_config_diff::Quantization {
442 fn from(value: ProductQuantizationBuilder) -> Self {
443 Self::Product(value.build())
444 }
445}
446
447impl From<BinaryQuantizationBuilder> for quantization_config_diff::Quantization {
448 fn from(value: BinaryQuantizationBuilder) -> Self {
449 Self::Binary(value.build())
450 }
451}
452
453impl From<ScalarQuantizationBuilder> for quantization_config::Quantization {
454 fn from(value: ScalarQuantizationBuilder) -> Self {
455 Self::Scalar(value.build())
456 }
457}
458
459impl From<ProductQuantizationBuilder> for quantization_config::Quantization {
460 fn from(value: ProductQuantizationBuilder) -> Self {
461 Self::Product(value.build())
462 }
463}
464
465impl From<BinaryQuantizationBuilder> for quantization_config::Quantization {
466 fn from(value: BinaryQuantizationBuilder) -> Self {
467 Self::Binary(value.build())
468 }
469}
470
471impl From<points_update_operation::PointStructList> for points_update_operation::Operation {
472 fn from(value: points_update_operation::PointStructList) -> Self {
473 Self::Upsert(value)
474 }
475}
476
477impl From<points_update_operation::SetPayload> for points_update_operation::Operation {
478 fn from(value: points_update_operation::SetPayload) -> Self {
479 Self::SetPayload(value)
480 }
481}
482
483impl From<points_update_operation::OverwritePayload> for points_update_operation::Operation {
484 fn from(value: points_update_operation::OverwritePayload) -> Self {
485 Self::OverwritePayload(value)
486 }
487}
488
489impl From<points_update_operation::DeletePayload> for points_update_operation::Operation {
490 fn from(value: points_update_operation::DeletePayload) -> Self {
491 Self::DeletePayload(value)
492 }
493}
494
495impl From<points_update_operation::UpdateVectors> for points_update_operation::Operation {
496 fn from(value: points_update_operation::UpdateVectors) -> Self {
497 Self::UpdateVectors(value)
498 }
499}
500
501impl From<points_update_operation::DeleteVectors> for points_update_operation::Operation {
502 fn from(value: points_update_operation::DeleteVectors) -> Self {
503 Self::DeleteVectors(value)
504 }
505}
506
507impl From<points_update_operation::DeletePoints> for points_update_operation::Operation {
508 fn from(value: points_update_operation::DeletePoints) -> Self {
509 Self::DeletePoints(value)
510 }
511}
512
513impl From<points_update_operation::ClearPayload> for points_update_operation::Operation {
514 fn from(value: points_update_operation::ClearPayload) -> Self {
515 Self::ClearPayload(value)
516 }
517}
518
519impl From<MoveShard> for update_collection_cluster_setup_request::Operation {
520 fn from(value: MoveShard) -> Self {
521 Self::MoveShard(value)
522 }
523}
524
525impl From<MoveShardBuilder> for update_collection_cluster_setup_request::Operation {
526 fn from(value: MoveShardBuilder) -> Self {
527 Self::MoveShard(value.build())
528 }
529}
530
531impl From<ReplicateShard> for update_collection_cluster_setup_request::Operation {
532 fn from(value: ReplicateShard) -> Self {
533 Self::ReplicateShard(value)
534 }
535}
536
537impl From<ReplicateShardBuilder> for update_collection_cluster_setup_request::Operation {
538 fn from(value: ReplicateShardBuilder) -> Self {
539 Self::ReplicateShard(value.build())
540 }
541}
542
543impl From<AbortShardTransfer> for update_collection_cluster_setup_request::Operation {
544 fn from(value: AbortShardTransfer) -> Self {
545 Self::AbortTransfer(value)
546 }
547}
548
549impl From<AbortShardTransferBuilder> for update_collection_cluster_setup_request::Operation {
550 fn from(value: AbortShardTransferBuilder) -> Self {
551 Self::AbortTransfer(value.build())
552 }
553}
554
555impl From<Replica> for update_collection_cluster_setup_request::Operation {
556 fn from(value: Replica) -> Self {
557 Self::DropReplica(value)
558 }
559}
560
561impl From<CreateShardKey> for update_collection_cluster_setup_request::Operation {
562 fn from(value: CreateShardKey) -> Self {
563 Self::CreateShardKey(value)
564 }
565}
566
567impl From<DeleteShardKey> for update_collection_cluster_setup_request::Operation {
568 fn from(value: DeleteShardKey) -> Self {
569 Self::DeleteShardKey(value)
570 }
571}
572
573impl From<RestartTransfer> for update_collection_cluster_setup_request::Operation {
574 fn from(value: RestartTransfer) -> Self {
575 Self::RestartTransfer(value)
576 }
577}