qdrant_client/grpc_conversions/
mod.rs

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