Skip to main content

Scoreable

Trait Scoreable 

Source
pub trait Scoreable: Send + Sync {
    // Required methods
    fn id(&self) -> &str;
    fn score_proxy(&self) -> f32;
    fn category(&self) -> &str;
    fn metadata(&self) -> &HashMap<String, String>;

    // Provided method
    fn prerequisites(&self) -> &[String] { ... }
}
Expand description

Trait that caller’s item type must implement.

The engine only needs three things from any item:

  • a stable unique ID
  • a normalised score proxy (0.0–1.0) used by built-in factors (difficulty in learning, price_ratio in ecommerce, remoteness in travel…)
  • a category/topic string for coverage factor

All other domain data lives in metadata() — accessible to custom factors.

Required Methods§

Source

fn id(&self) -> &str

Source

fn score_proxy(&self) -> f32

Normalised difficulty/complexity proxy. Range [0.0, 1.0]. Caller defines what this means in their domain.

Source

fn category(&self) -> &str

Category label used for coverage balancing. e.g. “algebra”, “electronics”, “beach”, “thriller”

Source

fn metadata(&self) -> &HashMap<String, String>

Arbitrary key-value metadata for custom factor logic.

Provided Methods§

Source

fn prerequisites(&self) -> &[String]

Prerequisite item IDs. Engine will not suggest this item until all prereqs appear in the user’s resolved_set.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§