pub trait DynamicModelBackend:
Clone
+ Send
+ Sync
+ 'static {
type Score: Score;
// Required methods
fn entity_count(&self, entity: EntityClassId) -> usize;
fn get_scalar(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> Option<usize>;
fn set_scalar(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
value: Option<usize>,
);
fn list_len(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> usize;
fn list_get(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
) -> Option<usize>;
fn list_insert(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
value: usize,
);
fn list_remove(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
) -> Option<usize>;
fn candidate_values(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> &[usize];
fn scalar_value_is_legal(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
value: usize,
) -> bool;
// Provided methods
fn list_element_count(
&self,
_entity: EntityClassId,
_variable: VariableId,
) -> usize { ... }
fn list_element(
&self,
_entity: EntityClassId,
_variable: VariableId,
element_index: usize,
) -> Option<usize> { ... }
fn list_assigned_elements(
&self,
_entity: EntityClassId,
_variable: VariableId,
) -> Vec<usize> { ... }
}Expand description
Rust-owned dynamic planning model backend.
Binding crates implement this trait on their concrete dynamic solution
state. The trait is expressed in logical entity and variable IDs rather
than Rust TypeIds.
Required Associated Types§
Required Methods§
Sourcefn entity_count(&self, entity: EntityClassId) -> usize
fn entity_count(&self, entity: EntityClassId) -> usize
Number of rows (entities) of class entity.
Sourcefn get_scalar(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> Option<usize>
fn get_scalar( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> Option<usize>
Value of a scalar variable on one row; None means unassigned.
Sourcefn set_scalar(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
value: Option<usize>,
)
fn set_scalar( &mut self, entity: EntityClassId, row: usize, variable: VariableId, value: Option<usize>, )
Assigns (Some) or unassigns (None) a scalar variable on one row.
Sourcefn list_len(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> usize
fn list_len( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> usize
Length of a list variable on one row.
Sourcefn list_get(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
) -> Option<usize>
fn list_get( &self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, ) -> Option<usize>
Element at pos in a row’s list; None when pos is out of range.
Sourcefn list_insert(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
value: usize,
)
fn list_insert( &mut self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, value: usize, )
Inserts value at pos in a row’s list.
Sourcefn list_remove(
&mut self,
entity: EntityClassId,
row: usize,
variable: VariableId,
pos: usize,
) -> Option<usize>
fn list_remove( &mut self, entity: EntityClassId, row: usize, variable: VariableId, pos: usize, ) -> Option<usize>
Removes and returns the element at pos in a row’s list; None when pos is out of range.
Sourcefn candidate_values(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
) -> &[usize]
fn candidate_values( &self, entity: EntityClassId, row: usize, variable: VariableId, ) -> &[usize]
Candidate values for a scalar variable on one row.
Sourcefn scalar_value_is_legal(
&self,
entity: EntityClassId,
row: usize,
variable: VariableId,
value: usize,
) -> bool
fn scalar_value_is_legal( &self, entity: EntityClassId, row: usize, variable: VariableId, value: usize, ) -> bool
Returns true when value is a legal assignment for a scalar variable on one row.
Provided Methods§
Sourcefn list_element_count(
&self,
_entity: EntityClassId,
_variable: VariableId,
) -> usize
fn list_element_count( &self, _entity: EntityClassId, _variable: VariableId, ) -> usize
Number of declared elements a list variable distributes; defaults to 0.
Sourcefn list_element(
&self,
_entity: EntityClassId,
_variable: VariableId,
element_index: usize,
) -> Option<usize>
fn list_element( &self, _entity: EntityClassId, _variable: VariableId, element_index: usize, ) -> Option<usize>
Element value at declared source index element_index; None when the
element is missing. Defaults to the index itself.
Sourcefn list_assigned_elements(
&self,
_entity: EntityClassId,
_variable: VariableId,
) -> Vec<usize>
fn list_assigned_elements( &self, _entity: EntityClassId, _variable: VariableId, ) -> Vec<usize>
Elements currently placed in any row’s list; defaults to none.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".