qdrant_edge/edge/types/
point.rs1use crate::segment::types::{ExtendedPointId, Payload};
2use serde_json::Value as JsonValue;
3use crate::shard::operations::point_ops::{PointStructPersisted, VectorStructPersisted};
4
5use super::Vectors;
6
7#[derive(Debug, Clone)]
8pub struct PointStruct(pub PointStructPersisted);
9
10impl PointStruct {
11 pub fn new(
12 id: impl Into<ExtendedPointId>,
13 vectors: impl Into<Vectors>,
14 payload: JsonValue,
15 ) -> Self {
16 let payload = match payload {
17 JsonValue::Object(map) => Payload(map.into_iter().collect()),
18 JsonValue::Null
19 | JsonValue::Bool(_)
20 | JsonValue::Number(_)
21 | JsonValue::String(_)
22 | JsonValue::Array(_) => panic!("payload must be a JSON object, got {payload}"),
23 };
24 Self(PointStructPersisted {
25 id: id.into(),
26 vector: VectorStructPersisted::from(vectors.into().0),
27 payload: Some(payload),
28 })
29 }
30}
31
32impl From<PointStruct> for PointStructPersisted {
33 fn from(p: PointStruct) -> Self {
34 p.0
35 }
36}
37
38impl From<PointStructPersisted> for PointStruct {
39 fn from(p: PointStructPersisted) -> Self {
40 Self(p)
41 }
42}