pub struct DynamicScalarVariableSlot<S> {
pub entity: EntityClassId,
pub variable: VariableId,
pub entity_type_name: &'static str,
pub variable_name: &'static str,
pub allows_unassigned: bool,
/* private fields */
}Expand description
Public dynamic scalar variable slot.
Fields§
§entity: EntityClassIdLogical entity class ID the slot is bound to.
variable: VariableIdLogical variable ID the slot is bound to.
entity_type_name: &'static strEntity type name, checked against the SolutionDescriptor on resolution.
variable_name: &'static strVariable name, checked against the SolutionDescriptor on resolution.
allows_unassigned: boolWhether the variable may be unassigned (None).
Implementations§
Source§impl<S> DynamicScalarVariableSlot<S>
impl<S> DynamicScalarVariableSlot<S>
Sourcepub fn with_access(
entity: EntityClassId,
variable: VariableId,
entity_type_name: &'static str,
variable_name: &'static str,
allows_unassigned: bool,
access: Arc<dyn DynamicScalarAccess<S>>,
) -> Self
pub fn with_access( entity: EntityClassId, variable: VariableId, entity_type_name: &'static str, variable_name: &'static str, allows_unassigned: bool, access: Arc<dyn DynamicScalarAccess<S>>, ) -> Self
Creates an unresolved slot over a custom access implementation.
Sourcepub fn resolve_descriptor_index(
&mut self,
descriptor: &SolutionDescriptor,
) -> Result<(), String>
pub fn resolve_descriptor_index( &mut self, descriptor: &SolutionDescriptor, ) -> Result<(), String>
Resolves this slot’s descriptor and variable indexes against descriptor.
Fails when the logical entity ID, entity type name, logical variable ID, variable name or variable kind do not match the descriptor, or when the slot was pre-bound to a different descriptor index.
Sourcepub fn resolved_against(
self,
descriptor: &SolutionDescriptor,
) -> Result<Self, String>
pub fn resolved_against( self, descriptor: &SolutionDescriptor, ) -> Result<Self, String>
Consuming form of resolve_descriptor_index.
Sourcepub fn is_descriptor_resolved(&self) -> bool
pub fn is_descriptor_resolved(&self) -> bool
Returns true once both the descriptor index and the variable index are resolved.
Sourcepub fn descriptor_index(&self) -> usize
pub fn descriptor_index(&self) -> usize
Index of this slot’s entity descriptor in the SolutionDescriptor.
§Panics
Panics if the slot has not been resolved against a SolutionDescriptor.
Sourcepub fn descriptor_variable_index(&self) -> usize
pub fn descriptor_variable_index(&self) -> usize
Index of this slot’s variable within its entity descriptor.
§Panics
Panics if the slot has not been resolved against a SolutionDescriptor.
Sourcepub fn matches_target(
&self,
entity_class: Option<&str>,
variable_name: Option<&str>,
) -> bool
pub fn matches_target( &self, entity_class: Option<&str>, variable_name: Option<&str>, ) -> bool
Returns true when this slot matches a configuration target; None for
either name matches any entity class or variable.
Sourcepub fn entity_count(&self, solution: &S) -> usize
pub fn entity_count(&self, solution: &S) -> usize
Number of rows of the bound entity class.
Sourcepub fn current_value(&self, solution: &S, row: usize) -> Option<usize>
pub fn current_value(&self, solution: &S, row: usize) -> Option<usize>
Value on one row; None means unassigned.
Sourcepub fn set_value(&self, solution: &mut S, row: usize, value: Option<usize>)
pub fn set_value(&self, solution: &mut S, row: usize, value: Option<usize>)
Assigns (Some) or unassigns (None) the value on one row.
Sourcepub fn candidate_values<'a>(&self, solution: &'a S, row: usize) -> &'a [usize]
pub fn candidate_values<'a>(&self, solution: &'a S, row: usize) -> &'a [usize]
Candidate values for one row.
Sourcepub fn has_nearby_value_candidates(&self) -> bool
pub fn has_nearby_value_candidates(&self) -> bool
Sourcepub fn visit_nearby_value_candidates(
&self,
solution: &S,
row: usize,
limit: usize,
visit: &mut dyn FnMut(usize),
) -> bool
pub fn visit_nearby_value_candidates( &self, solution: &S, row: usize, limit: usize, visit: &mut dyn FnMut(usize), ) -> bool
Sourcepub fn nearby_value_distance(
&self,
solution: &S,
row: usize,
candidate: usize,
) -> Option<f64>
pub fn nearby_value_distance( &self, solution: &S, row: usize, candidate: usize, ) -> Option<f64>
Sourcepub fn has_nearby_entity_candidates(&self) -> bool
pub fn has_nearby_entity_candidates(&self) -> bool
Sourcepub fn visit_nearby_entity_candidates(
&self,
solution: &S,
left_row: usize,
limit: usize,
visit: &mut dyn FnMut(usize),
) -> bool
pub fn visit_nearby_entity_candidates( &self, solution: &S, left_row: usize, limit: usize, visit: &mut dyn FnMut(usize), ) -> bool
Source§impl<S> DynamicScalarVariableSlot<S>where
S: DynamicModelBackend,
impl<S> DynamicScalarVariableSlot<S>where
S: DynamicModelBackend,
Sourcepub fn new(
entity: EntityClassId,
variable: VariableId,
entity_type_name: &'static str,
variable_name: &'static str,
allows_unassigned: bool,
) -> Self
pub fn new( entity: EntityClassId, variable: VariableId, entity_type_name: &'static str, variable_name: &'static str, allows_unassigned: bool, ) -> Self
Creates a slot whose access is the model backend itself.