#[non_exhaustive]pub enum DistanceMetric {
Cosine,
DotProduct,
Euclidean,
Manhattan,
Hamming,
}Expand description
The metric used to measure distance (or similarity) between two vectors.
Which metric is valid depends on how the vectors were produced — cosine and dot product suit normalized embeddings, the geometric metrics suit raw coordinates, and Hamming suits binary codes. The engine selects the matching comparison from this tag.
§Examples
use iqdb_types::DistanceMetric;
let metric = DistanceMetric::Cosine;
assert_eq!(metric, DistanceMetric::Cosine);
assert_ne!(metric, DistanceMetric::Euclidean);The enum is #[non_exhaustive]: future releases may add metrics (for
example, Jaccard or Chebyshev) without it being a breaking change, so a
match on it from another crate must include a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Cosine
Cosine distance — the angle between vectors, ignoring magnitude. Suits normalized embeddings.
DotProduct
Dot-product similarity — magnitude-sensitive inner product. Suits embeddings where magnitude carries signal.
Euclidean
Euclidean (L2) distance — straight-line distance between coordinates.
Manhattan
Manhattan (L1) distance — sum of absolute per-component differences.
Hamming
Hamming distance — count of differing positions. Suits binary codes.
Trait Implementations§
Source§impl Clone for DistanceMetric
impl Clone for DistanceMetric
Source§fn clone(&self) -> DistanceMetric
fn clone(&self) -> DistanceMetric
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DistanceMetric
Source§impl Debug for DistanceMetric
impl Debug for DistanceMetric
Source§impl<'de> Deserialize<'de> for DistanceMetric
impl<'de> Deserialize<'de> for DistanceMetric
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>,
impl Eq for DistanceMetric
Source§impl Hash for DistanceMetric
impl Hash for DistanceMetric
Source§impl PartialEq for DistanceMetric
impl PartialEq for DistanceMetric
Source§fn eq(&self, other: &DistanceMetric) -> bool
fn eq(&self, other: &DistanceMetric) -> bool
self and other values to be equal, and is used by ==.