summavy/query/
scorer.rs

1use std::ops::DerefMut;
2
3use downcast_rs::impl_downcast;
4
5use crate::docset::DocSet;
6use crate::Score;
7
8/// Scored set of documents matching a query within a specific segment.
9///
10/// See [`Query`](crate::query::Query).
11pub trait Scorer: downcast_rs::Downcast + DocSet + 'static {
12    /// Returns the score.
13    ///
14    /// This method will perform a bit of computation and is not cached.
15    fn score(&mut self) -> Score;
16}
17
18impl_downcast!(Scorer);
19
20impl Scorer for Box<dyn Scorer> {
21    fn score(&mut self) -> Score {
22        self.deref_mut().score()
23    }
24}