Skip to main content

Crate score_set

Crate score_set 

Source
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

LayerTypeDispatchWhen to use
1 — fixedFixedScoreSet via fixed_score_set!Compile-time, zero vtableKnown metric set at compile time
2 — finiteFiniteScoreSet via finite_score_set!Enum match, zero vtableRuntime composition, known metric types
3 — dynamicDynamicScoreSet via dynamic_score_set!Vtable per callFully 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§

finite_enum

Macros§

dynamic_score_set
Declare a dynamic set of weight => metric pairs (Layer 3).
finite_metric
Declare a finite enum of metric types with static-dispatch eval.
finite_score_set
Declare a finite set of weight => metric pairs (Layer 2).
fixed_score_set
Declare a fixed set of weight => metric pairs (Layer 1).

Structs§

Breakdown
A single metric’s contribution in a score breakdown.
DynamicMember
A member of a DynamicScoreSet: a normalized weight paired with a type-erased metric.
DynamicScoreSet
A weighted set of scoring operators using dynamic dispatch.
DynamicScoreSetBuilder
Incremental builder for DynamicScoreSet.
DynamicScoreStage
The scoring stage for a DynamicScoreSet, created by DynamicScoreSet::score.
FiniteMember
A member of a FiniteScoreSet: a normalized weight paired with a metric enum variant.
FiniteScoreSet
A weighted set of scoring operators using enum-based static dispatch.
FiniteScoreSetBuilder
Incremental builder for FiniteScoreSet.
FiniteScoreStage
The scoring stage for a FiniteScoreSet, created by FiniteScoreSet::score.
FixedScoreSet
A compile-time fixed weighted set of scoring operators with normalized weights.
FixedScoreStage
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.
NormalizedContainer
Witness credential for a container validated as a complete set of normalized weights (each in [0, 1], sum to 1).
NormalizedWeight
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.
WitnessExt
Extension trait for starting a witnessing pipeline.

Functions§

metric
Entry point: metric("name").