use common::types::ScoreType; use crate::common::operation_error::{OperationError, OperationResult}; use crate::data_types::vectors::DenseVector; mod context_query; mod discovery_query; mod reco_query; pub use context_query::{ContextPair, ContextQuery}; pub use discovery_query::DiscoveryQuery; pub use reco_query::RecoQuery; pub trait TransformInto { /// Change the underlying type of the query, or just process it in some way. fn transform(self, f: F) -> OperationResult where F: FnMut(T) -> OperationResult; fn transform_into(self) -> OperationResult where Self: Sized, T: TryInto, { self.transform(|v| v.try_into()) } } pub trait Query { /// Compares the vectors of the query against a single vector via a similarity function, /// then folds the similarites into a single score. fn score_by(&self, similarity: impl Fn(&T) -> ScoreType) -> ScoreType; }