pub struct ObjectiveRegistry<T: Send + Sync> { /* private fields */ }Expand description
Registry of named objectives.
Thread-safe: all operations are behind a single RwLock.
Implementations§
Source§impl<T: Send + Sync> ObjectiveRegistry<T>
impl<T: Send + Sync> ObjectiveRegistry<T>
pub fn new() -> Self
pub fn register( &self, name: impl Into<String>, objective: Box<dyn Objective<T>>, ) -> Option<Arc<RegisteredObjective<T>>>
pub fn register_with_desc( &self, name: impl Into<String>, description: impl Into<String>, objective: Box<dyn Objective<T>>, ) -> Option<Arc<RegisteredObjective<T>>>
pub fn set_default(&self, name: impl Into<String>) -> ObjectiveResult<()>
pub fn get(&self, name: &str) -> ObjectiveResult<Arc<RegisteredObjective<T>>>
pub fn get_default(&self) -> ObjectiveResult<Arc<RegisteredObjective<T>>>
pub fn list(&self) -> Vec<String>
pub fn contains(&self, name: &str) -> bool
Sourcepub fn score(
&self,
name: &str,
candidate: &T,
context: &ObjectiveContext,
) -> ObjectiveResult<f64>
pub fn score( &self, name: &str, candidate: &T, context: &ObjectiveContext, ) -> ObjectiveResult<f64>
Raw score via a named objective (no precision weighting).
pub fn select<'a>( &self, name: &str, candidates: &'a [T], context: &ObjectiveContext, ) -> ObjectiveResult<Selection<&'a T>>
pub fn select_default<'a>( &self, candidates: &'a [T], context: &ObjectiveContext, ) -> ObjectiveResult<Selection<&'a T>>
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for ObjectiveRegistry<T>
impl<T> !RefUnwindSafe for ObjectiveRegistry<T>
impl<T> Send for ObjectiveRegistry<T>
impl<T> Sync for ObjectiveRegistry<T>
impl<T> Unpin for ObjectiveRegistry<T>
impl<T> UnsafeUnpin for ObjectiveRegistry<T>
impl<T> !UnwindSafe for ObjectiveRegistry<T>
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