pub struct VectorAnnotatedRecord {
pub cid: String,
pub vector: Vec<f32>,
pub dimension: usize,
pub provider_id: String,
pub ttl_secs: u64,
pub metadata: HashMap<String, String>,
}Expand description
A DHT record that carries an embedded vector alongside the CID it annotates.
VectorAnnotatedRecord is the wire format stored in the DHT; it allows any
peer that retrieves the record to immediately compute similarity without
fetching additional metadata.
Fields§
§cid: StringContent identifier this record refers to
vector: Vec<f32>Embedding vector for the content
dimension: usizeDimensionality of vector (stored separately for fast validation)
provider_id: StringPeerId (string-encoded) of the peer that published this record
ttl_secs: u64How long (in seconds) this record should be considered fresh
metadata: HashMap<String, String>Arbitrary application-level metadata (e.g. content-type, language, …)
Implementations§
Source§impl VectorAnnotatedRecord
impl VectorAnnotatedRecord
Sourcepub fn new(
cid: impl Into<String>,
vector: Vec<f32>,
provider_id: impl Into<String>,
ttl_secs: u64,
metadata: HashMap<String, String>,
) -> Self
pub fn new( cid: impl Into<String>, vector: Vec<f32>, provider_id: impl Into<String>, ttl_secs: u64, metadata: HashMap<String, String>, ) -> Self
Construct a new VectorAnnotatedRecord, deriving dimension from vector.
Sourcepub fn is_consistent(&self) -> bool
pub fn is_consistent(&self) -> bool
Check whether vector.len() == dimension (should always be true for
well-formed records received from trusted peers; useful after deserde).
Trait Implementations§
Source§impl Clone for VectorAnnotatedRecord
impl Clone for VectorAnnotatedRecord
Source§fn clone(&self) -> VectorAnnotatedRecord
fn clone(&self) -> VectorAnnotatedRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for VectorAnnotatedRecord
impl Debug for VectorAnnotatedRecord
Source§impl<'de> Deserialize<'de> for VectorAnnotatedRecord
impl<'de> Deserialize<'de> for VectorAnnotatedRecord
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for VectorAnnotatedRecord
impl RefUnwindSafe for VectorAnnotatedRecord
impl Send for VectorAnnotatedRecord
impl Sync for VectorAnnotatedRecord
impl Unpin for VectorAnnotatedRecord
impl UnsafeUnpin for VectorAnnotatedRecord
impl UnwindSafe for VectorAnnotatedRecord
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more