Skip to main content

Crate score_set

Crate score_set 

Source
Expand description

§score-set

A #![no_std] + alloc Rust library for building weighted scoring operators — define metrics via a builder pipeline, combine them into a zero-vtable flat scorer with the score_set32! macro.

§Quick example

use score_set::*;

struct Restaurant {
    cleanliness: f32,
    food_quality: f32,
}

let clean = metric32("cleanliness")
    .measure()
    .by(|r: &Restaurant| r.cleanliness)
    .map01()
    .linear(100.0);

let food = metric32("food")
    .measure()
    .by(|r: &Restaurant| r.food_quality)
    .map01()
    .identity();

let scorer = score_set32! { 2.0 => clean, 1.0 => food }?;

let r = Restaurant { cleanliness: 80.0, food_quality: 4.0 };
let total: f32 = scorer.score(&r);
let rows = scorer.breakdown(&r);

§Partial application

by() accepts capturing closures, enabling parameter binding at construction time:

let threshold: f32 = 0.6;
let quality = metric32("quality")
    .measure()
    .by(move |ctx: &MyCtx| if ctx.value > threshold { ctx.value } else { 0.0 })
    .map01()
    .identity();

let scorer = score_set32! { 1.0 => quality }?;
// scorer only needs &MyCtx — threshold is baked in

§no_std

This crate is #![no_std] with extern crate alloc — it only needs Vec from the allocator and works on bare-metal targets.

Macros§

score_set32
Combine heterogeneous metrics into a zero-vtable, zero-heap-allocation weighted scorer.

Structs§

Breakdown32
A single metric’s contribution to the total score.
GtZero
Witness credential for a value validated to be finite and strictly > 0.
Map01Stage32
Waiting for a normalization strategy.
MeasureStage32
Waiting for a measure function.
MeasuredStage32
Has a measure function, waiting for a Map0132 strategy.
Metric32
A single named scoring metric with its normalization strategy.
MetricNamingStage32
Entry point for building a Metric32.
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.
Scored32
A validated weighted scorer holding a flat tuple 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§

ScoreSetTrait32
Trait implemented by tuples of Metric32s for weighted evaluation.
WitnessExt
Extension trait for starting a witnessing pipeline.

Functions§

metric32
Create a new metric with the given name.