score_set/traits.rs
1/// Measures a context and returns an `f64` value.
2pub trait MeasureF64<Ctx: ?Sized>: Send + Sync {
3 /// Extracts a measurable value from `ctx`.
4 fn measure(&self, ctx: &Ctx) -> f64;
5}
6
7/// Maps an `f64` value into the `[0, 1]` range.
8pub trait Map01F64: Send + Sync {
9 /// Converts `value` into a normalized score.
10 fn map(&self, value: f64) -> f64;
11}
12
13/// Evaluates a context into an `f64` score.
14pub trait EvalF64<Ctx: ?Sized>: Send + Sync {
15 /// Computes a score from `ctx`.
16 fn eval(&self, ctx: &Ctx) -> f64;
17}
18
19/// Measures a context and returns an `f32` value.
20pub trait MeasureF32<Ctx: ?Sized>: Send + Sync {
21 /// Extracts a measurable value from `ctx`.
22 fn measure(&self, ctx: &Ctx) -> f32;
23}
24
25/// Maps an `f32` value into the `[0, 1]` range.
26pub trait Map01F32: Send + Sync {
27 /// Converts `value` into a normalized score.
28 fn map(&self, value: f32) -> f32;
29}
30
31/// Evaluates a context into an `f32` score.
32pub trait EvalF32<Ctx: ?Sized>: Send + Sync {
33 /// Computes a score from `ctx`.
34 fn eval(&self, ctx: &Ctx) -> f32;
35}