Skip to main content

qdrant_edge/edge/types/
point.rs

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