pub struct RuleEngine { /* private fields */ }Expand description
A composable rule engine for task prioritization.
Supports sequential multi-layer evaluation (primary rule → tie-breaker) and weighted combination modes.
§Example
use u_schedule::dispatching::{RuleEngine, SchedulingContext};
use u_schedule::dispatching::rules;
let engine = RuleEngine::new()
.with_rule(rules::Edd)
.with_tie_breaker(rules::Spt);Implementations§
Source§impl RuleEngine
impl RuleEngine
Sourcepub fn with_rule<R: DispatchingRule + 'static>(self, rule: R) -> Self
pub fn with_rule<R: DispatchingRule + 'static>(self, rule: R) -> Self
Adds a primary rule (weight 1.0).
Sourcepub fn with_weighted_rule<R: DispatchingRule + 'static>(
self,
rule: R,
weight: f64,
) -> Self
pub fn with_weighted_rule<R: DispatchingRule + 'static>( self, rule: R, weight: f64, ) -> Self
Adds a weighted rule.
Sourcepub fn with_tie_breaker<R: DispatchingRule + 'static>(self, rule: R) -> Self
pub fn with_tie_breaker<R: DispatchingRule + 'static>(self, rule: R) -> Self
Adds a tie-breaking rule (weight 0.0, used only in Sequential mode).
Sourcepub fn with_mode(self, mode: EvaluationMode) -> Self
pub fn with_mode(self, mode: EvaluationMode) -> Self
Sets the evaluation mode.
Sourcepub fn with_final_tie_breaker(self, tie_breaker: TieBreaker) -> Self
pub fn with_final_tie_breaker(self, tie_breaker: TieBreaker) -> Self
Sets the final tie-breaking strategy.
Sourcepub fn sort_indices(
&self,
tasks: &[Task],
context: &SchedulingContext,
) -> Vec<usize>
pub fn sort_indices( &self, tasks: &[Task], context: &SchedulingContext, ) -> Vec<usize>
Sorts tasks by priority (highest priority first).
Returns indices into the original task slice, sorted by rule evaluation.
Sourcepub fn select_best(
&self,
tasks: &[Task],
context: &SchedulingContext,
) -> Option<usize>
pub fn select_best( &self, tasks: &[Task], context: &SchedulingContext, ) -> Option<usize>
Returns the index of the highest-priority task.
Trait Implementations§
Source§impl Clone for RuleEngine
impl Clone for RuleEngine
Source§fn clone(&self) -> RuleEngine
fn clone(&self) -> RuleEngine
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 RuleEngine
impl Debug for RuleEngine
Auto Trait Implementations§
impl Freeze for RuleEngine
impl !RefUnwindSafe for RuleEngine
impl Send for RuleEngine
impl Sync for RuleEngine
impl Unpin for RuleEngine
impl UnsafeUnpin for RuleEngine
impl !UnwindSafe for RuleEngine
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