diskann_label_filter/
document.rs1use crate::attribute::Attribute;
7use diskann_utils::reborrow::Reborrow;
8
9pub struct Document<'a, V> {
12 vector: &'a V,
13 attributes: Vec<Attribute>,
14}
15
16impl<'a, V> Document<'a, V> {
17 pub fn new(vector: &'a V, attributes: Vec<Attribute>) -> Self {
18 Self { vector, attributes }
19 }
20
21 pub(crate) fn vector(&self) -> &'a V {
22 self.vector
23 }
24
25 pub(crate) fn attributes(&self) -> &Vec<Attribute> {
26 &self.attributes
27 }
28}
29
30#[derive(Clone)]
33pub struct EncodedDocument<V, ST> {
34 vector: V,
35 attributes: ST,
36}
37
38impl<V, ST> EncodedDocument<V, ST> {
39 pub fn new(vector: V, attributes: ST) -> Self {
40 Self { vector, attributes }
41 }
42
43 pub fn destructure(self) -> (V, ST) {
44 (self.vector, self.attributes)
45 }
46
47 pub(crate) fn attributes(&self) -> &ST {
48 &self.attributes
49 }
50}
51
52impl<'this, V, ST> Reborrow<'this> for EncodedDocument<V, ST>
54where
55 V: Reborrow<'this>,
56{
57 type Target = EncodedDocument<V::Target, &'this ST>;
58
59 fn reborrow(&'this self) -> Self::Target {
60 EncodedDocument::new(self.vector.reborrow(), &self.attributes)
61 }
62}