Expand description
§score-set
A Rust library for building weighted scoring operator sets with three dispatch strategies — from compile-time fixed to fully dynamic.
It does not prescribe a unified input or context type. Instead it declares, stores, normalizes, and combines a set of weighted operators.
§Three-layer architecture
| Layer | Type | Dispatch | When to use |
|---|---|---|---|
| 1 — fixed | FixedScoreSet via fixed_score_set! | Compile-time, zero vtable | Known metric set at compile time |
| 2 — finite | FiniteScoreSet via finite_score_set! | Enum match, zero vtable | Runtime composition, known metric types |
| 3 — dynamic | DynamicScoreSet via dynamic_score_set! | Vtable per call | Fully heterogeneous, runtime assembly |
§Quick example (Layer 1 — fixed)
ⓘ
use score_set::*;
let gc = metric("gc")
.measure().by(|dna: &&str| gc_ratio(dna))
.map01().by(|raw: &f64, _: &&str| Value01::witness(*raw).unwrap());
let len = metric("len")
.measure().by(|len: &usize| *len)
.map01().by(|raw: &usize, _: &usize| {
Value01::witness((*raw as f64 / 100.0).min(1.0)).unwrap()
});
let ms = fixed_score_set! {
2.0 => gc,
3.0 => len,
}?;
let dna = "ACGTACGT";
let score = ms.score().by(|(gc, len)| {
gc.contribute(gc.metric().eval(&dna))
+ len.contribute(len.metric().eval(&dna.len()))
});Re-exports§
pub use finite_enum::*;
Modules§
Macros§
- dynamic_
score_ set - Declare a dynamic set of
weight => metricpairs (Layer 3). - finite_
metric - Declare a finite enum of metric types with static-dispatch
eval. - finite_
score_ set - Declare a finite set of
weight => metricpairs (Layer 2). - fixed_
score_ set - Declare a fixed set of
weight => metricpairs (Layer 1).
Structs§
- Breakdown
- A single metric’s contribution in a score breakdown.
- Dynamic
Member - A member of a
DynamicScoreSet: a normalized weight paired with a type-erased metric. - Dynamic
Score Set - A weighted set of scoring operators using dynamic dispatch.
- Dynamic
Score SetBuilder - Incremental builder for
DynamicScoreSet. - Dynamic
Score Stage - The scoring stage for a
DynamicScoreSet, created byDynamicScoreSet::score. - Finite
Member - A member of a
FiniteScoreSet: a normalized weight paired with a metric enum variant. - Finite
Score Set - A weighted set of scoring operators using enum-based static dispatch.
- Finite
Score SetBuilder - Incremental builder for
FiniteScoreSet. - Finite
Score Stage - The scoring stage for a
FiniteScoreSet, created byFiniteScoreSet::score. - Fixed
Score Set - A compile-time fixed weighted set of scoring operators with normalized weights.
- Fixed
Score Stage - The scoring stage, created by
FixedScoreSet::score. - GtZero
- Witness credential for a value validated to be finite and strictly > 0.
- Member
- A member of a
MetricSet: a normalized weight paired with its metric. - Metric
- A scoring operator built via the
measure().by() → map01().by()pipeline. - Normalized
Container - Witness credential for a container validated as a complete set of
normalized weights (each in
[0, 1], sum to 1). - Normalized
Weight - Witness credential for a single normalized weight.
- Value01
- Witness credential for a value validated to be finite and in
[0, 1]. - Witnessed
Traits§
- Float
- Public trait bound for floating-point types used throughout
score-set. - Scorable
- A type-erased metric that can be evaluated against input
I. - Witness
Ext - Extension trait for starting a witnessing pipeline.
Functions§
- metric
- Entry point:
metric("name").