pub mod backends;
pub mod score_result;
pub mod vector;
use crate::location::state::LocationView;
use crate::schema::schema::Schema;
pub use score_result::{Candidate, ScoreResult};
pub trait Scorer: Send + Sync {
fn score(&self, state: &LocationView<'_>) -> f32;
}
pub trait ScorerBuilder: Send + Sync {
type Scorer: Scorer + 'static;
fn build(&self, spec: &ScorerSpec<'_>, schema: &Schema) -> Result<Self::Scorer, BuildErr>;
}
#[derive(Clone, Debug)]
pub enum ScorerSpec<'a> {
Predicate(&'a str),
Vector {
target: &'a [f32],
metric: VectorMetric,
},
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VectorMetric {
Dot,
Cosine,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum VectorBackend {
Linear,
}
#[derive(Debug, thiserror::Error)]
pub enum BuildErr {
#[error("parse error: {0}")]
Parse(String),
#[error("unknown kind referenced: {0}")]
UnknownKind(String),
#[error("unknown attribute referenced: {0}")]
UnknownAttr(String),
#[error("type error: {0}")]
Type(String),
#[error("vector backend mismatch: {0}")]
Vector(String),
}