pub struct CalculatorBuilder { /* private fields */ }Expand description
Enhanced builder for creating Calculator instances
Provides a fluent API with validation, presets, and custom bonus configurations.
§Example
use reputation_core::{Calculator, CalculatorPreset};
// Using presets
let calc = Calculator::builder()
.preset(CalculatorPreset::Testing)
.build()
.unwrap();
// Custom configuration
let calc = Calculator::builder()
.confidence_k(20.0)
.prior_base(60.0)
.prior_max(90.0)
.build()
.unwrap();Implementations§
Source§impl CalculatorBuilder
impl CalculatorBuilder
Sourcepub fn confidence_k(self, k: f64) -> Self
pub fn confidence_k(self, k: f64) -> Self
Set confidence growth parameter (k in the formula)
Higher values result in slower confidence growth. Must be positive.
§Example
use reputation_core::Calculator;
let calc = Calculator::builder()
.confidence_k(20.0) // Slower growth
.build()
.unwrap();Sourcepub fn prior_base(self, base: f64) -> Self
pub fn prior_base(self, base: f64) -> Self
Set base prior score (starting reputation)
Must be between 0 and 100.
§Example
use reputation_core::Calculator;
let calc = Calculator::builder()
.prior_base(60.0) // Higher starting score
.build()
.unwrap();Sourcepub fn prior_max(self, max: f64) -> Self
pub fn prior_max(self, max: f64) -> Self
Set maximum prior score (cap for credential bonuses)
Must be between prior_base and 100.
§Example
use reputation_core::Calculator;
let calc = Calculator::builder()
.prior_base(50.0)
.prior_max(85.0) // Higher ceiling
.build()
.unwrap();Sourcepub fn prior_bonuses(self, bonuses: BonusConfig) -> Self
pub fn prior_bonuses(self, bonuses: BonusConfig) -> Self
Set custom bonus configuration
Allows fine-tuning of individual credential bonuses.
§Example
use reputation_core::{Calculator, BonusConfig};
let bonuses = BonusConfig {
mcp_bonus_per_level: 7.0, // Higher MCP bonus
identity_bonus: 10.0, // Higher identity bonus
..Default::default()
};
let calc = Calculator::builder()
.prior_bonuses(bonuses)
.build()
.unwrap();Sourcepub fn preset(self, preset: CalculatorPreset) -> Self
pub fn preset(self, preset: CalculatorPreset) -> Self
Apply a preset configuration
Presets provide tested configurations for common scenarios. Individual settings can still be overridden after applying a preset.
§Example
use reputation_core::{Calculator, CalculatorPreset};
// Use testing preset with custom prior_base
let calc = Calculator::builder()
.preset(CalculatorPreset::Testing)
.prior_base(55.0) // Override preset's prior_base
.build()
.unwrap();Sourcepub fn from_config(self, config: CalculatorConfig) -> Self
pub fn from_config(self, config: CalculatorConfig) -> Self
Load configuration from a CalculatorConfig
§Example
use reputation_core::{Calculator, CalculatorConfig};
let config = CalculatorConfig::default();
let calc = Calculator::builder()
.from_config(config)
.build()
.unwrap();Sourcepub fn config(&self) -> CalculatorConfig
pub fn config(&self) -> CalculatorConfig
Get the current configuration (for inspection)
Sourcepub fn build(self) -> Result<Calculator>
pub fn build(self) -> Result<Calculator>
Trait Implementations§
Source§impl Clone for CalculatorBuilder
impl Clone for CalculatorBuilder
Source§fn clone(&self) -> CalculatorBuilder
fn clone(&self) -> CalculatorBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CalculatorBuilder
impl Debug for CalculatorBuilder
Auto Trait Implementations§
impl Freeze for CalculatorBuilder
impl RefUnwindSafe for CalculatorBuilder
impl Send for CalculatorBuilder
impl Sync for CalculatorBuilder
impl Unpin for CalculatorBuilder
impl UnwindSafe for CalculatorBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more