Expand description
§score-set
A Rust library for building weighted scoring operators as composable closures.
Define metrics via a builder pipeline, combine them with weights, and
produce a closure — either a weighted sum function or a breakdown iterator.
The downstream caller only sees impl Fn(&C) -> Score or
impl Fn(&C) -> Vec<Breakdown>.
§Quick example
ⓘ
use score_set::*;
struct DnaCtx<'a> {
dna: &'a str,
len: usize,
}
let gc = metric32("gc")
.measure()
.by(|ctx: &DnaCtx| gc_ratio(ctx.dna) as f32)
.map01()
.identity();
let len = metric32("len")
.measure()
.by(|ctx: &DnaCtx| ctx.len as f32)
.map01()
.linear(100.0);
let scorer = ScoreSet32::new()
.push(2.0, gc)?
.push(1.0, len)?
.sum()?;
let ctx = DnaCtx { dna: "ACGTACGT", len: 8 };
let total = scorer(&ctx);§no_std
This crate is #![no_std] with extern crate alloc — it only needs
Vec and String from the allocator and works on bare-metal targets.
Structs§
- Breakdown32
- A single metric’s contribution to the total score.
- GtZero
- Witness credential for a value validated to be finite and strictly > 0.
- Map01
Stage32 - Waiting for a normalization strategy.
- Measure
Stage32 - Waiting for a measure function.
- Measured
Stage32 - Has a measure function, waiting for a
Map0132strategy. - Metric32
- A single named scoring metric with its normalization strategy.
- Metric
Naming Stage32 - Entry point for building a
Metric32. - 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.
- Score
Set32 - Builder for a weighted set of
Metric32s. - Value01
- Witness credential for a value validated to be finite and in
[0, 1]. - Witnessed
Enums§
- Map0132
- Normalization strategy that maps a raw measure to
[0, 1].
Traits§
- Score
Ops - Minimal trait for types usable as scores (weights, normalized values).
- Witness
Ext - Extension trait for starting a witnessing pipeline.
Functions§
- metric32
- Create a new metric with the given name.
Type Aliases§
- Score32
- The floating-point type used for all scores, weights, and contributions.