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§
Sourcefn count(&self, solution: &dyn Any) -> Option<usize>
fn count(&self, solution: &dyn Any) -> Option<usize>
Returns the number of entities in the collection.
Sourcefn get<'a>(&self, solution: &'a dyn Any, index: usize) -> Option<&'a dyn Any>
fn get<'a>(&self, solution: &'a dyn Any, index: usize) -> Option<&'a dyn Any>
Gets a reference to an entity by index.
Sourcefn get_mut<'a>(
&self,
solution: &'a mut dyn Any,
index: usize,
) -> Option<&'a mut dyn Any>
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.
Sourcefn entity_refs(&self, solution: &dyn Any) -> Vec<EntityRef>
fn entity_refs(&self, solution: &dyn Any) -> Vec<EntityRef>
Returns an iterator over entity references.
Sourcefn clone_box(&self) -> Box<dyn EntityExtractor>
fn clone_box(&self) -> Box<dyn EntityExtractor>
Clone this extractor.
Sourcefn clone_entity_boxed(
&self,
solution: &dyn Any,
index: usize,
) -> Option<Box<dyn Any + Send + Sync>>
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.
Sourcefn entity_type_id(&self) -> TypeId
fn entity_type_id(&self) -> TypeId
Returns the TypeId of the entity type.