Skip to main content

Crate score_set

Crate score_set 

Source
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.
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.
ScoreSet32
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§

ScoreOps
Minimal trait for types usable as scores (weights, normalized values).
WitnessExt
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.