EntityExtractor

Trait EntityExtractor 

Source
pub trait EntityExtractor: Send + Sync {
    // Required methods
    fn count(&self, solution: &dyn Any) -> Option<usize>;
    fn get<'a>(
        &self,
        solution: &'a dyn Any,
        index: usize,
    ) -> Option<&'a dyn Any>;
    fn get_mut<'a>(
        &self,
        solution: &'a mut dyn Any,
        index: usize,
    ) -> Option<&'a mut dyn Any>;
    fn entity_refs(&self, solution: &dyn Any) -> Vec<EntityRef>;
    fn clone_box(&self) -> Box<dyn EntityExtractor>;
    fn clone_entity_boxed(
        &self,
        solution: &dyn Any,
        index: usize,
    ) -> Option<Box<dyn Any + Send + Sync>>;
    fn entity_type_id(&self) -> TypeId;
}
Expand description

Trait for extracting entities from a planning solution.

This trait is implemented by closures/functions that can extract entity references from a solution of a specific type.

Required Methods§

Source

fn count(&self, solution: &dyn Any) -> Option<usize>

Returns the number of entities in the collection.

Source

fn get<'a>(&self, solution: &'a dyn Any, index: usize) -> Option<&'a dyn Any>

Gets a reference to an entity by index.

Source

fn get_mut<'a>( &self, solution: &'a mut dyn Any, index: usize, ) -> Option<&'a mut dyn Any>

Gets a mutable reference to an entity by index.

Source

fn entity_refs(&self, solution: &dyn Any) -> Vec<EntityRef>

Returns an iterator over entity references.

Source

fn clone_box(&self) -> Box<dyn EntityExtractor>

Clone this extractor.

Source

fn clone_entity_boxed( &self, solution: &dyn Any, index: usize, ) -> Option<Box<dyn Any + Send + Sync>>

Clones an entity as a boxed value for insertion into the constraint session.

This is used for incremental scoring where entities need to be inserted into the BAVET session as owned, type-erased values.

Source

fn entity_type_id(&self) -> TypeId

Returns the TypeId of the entity type.

Trait Implementations§

Source§

impl Clone for Box<dyn EntityExtractor>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementors§

Source§

impl<S, E> EntityExtractor for TypedEntityExtractor<S, E>
where S: Send + Sync + 'static, E: Clone + Send + Sync + 'static,