Trait biodivine_sketchbook::sketchbook::Manager

source ·
pub trait Manager {
    // Provided methods
    fn generate_id<T>(
        &self,
        ideal_id: &str,
        is_taken: &dyn Fn(&Self, &T) -> bool,
        num_indices: usize,
        start_index: Option<usize>,
    ) -> T
       where T: FromStr,
             <T as FromStr>::Err: Debug { ... }
    fn assert_ids_unique_and_used<T>(
        &self,
        id_list: &Vec<&str>,
        assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>,
    ) -> Result<(), String>
       where T: Eq + Hash + Debug + FromStr,
             <T as FromStr>::Err: Debug { ... }
    fn assert_ids_unique_and_new<T>(
        &self,
        id_list: &Vec<&str>,
        assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>,
    ) -> Result<(), String>
       where T: Eq + Hash + Debug + FromStr,
             <T as FromStr>::Err: Debug { ... }
}
Expand description

Trait implementing functionality relevant for all manager structs (such as ModelState, ObservationManager, …).

Provided Methods§

source

fn generate_id<T>( &self, ideal_id: &str, is_taken: &dyn Fn(&Self, &T) -> bool, num_indices: usize, start_index: Option<usize>, ) -> T
where T: FromStr, <T as FromStr>::Err: Debug,

Generate an ID of type T for a certain component of a manager (e.g., generate a VariableId for a Variable in a ModelState).

The id is generated based on provided ideal_id. In best case, it is used directly. If this would cause some collisions, it is modified by adding index at the end until the ID becomes unique. By specifying start_index, the index search starts directly at that number (e.g., when ideal ID is “var” and start index is 3, search for ID starts with “var_3”, “var_4”, …)

Method is_taken is provided to check whether a generated id is already taken (non-unique), and num_indices specifies maximum number of different indices that might be needed to be explored to make the id unique (e.g., for a variable, it would be total number of variables used).

source

fn assert_ids_unique_and_used<T>( &self, id_list: &Vec<&str>, assert_id_is_managed: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are already managed by the manager instance (this is important, for instance, when we need to change already existing elements).

Manager class’ method to assert ID validity must be provided.

source

fn assert_ids_unique_and_new<T>( &self, id_list: &Vec<&str>, assert_id_is_new: &dyn Fn(&Self, &T) -> Result<(), String>, ) -> Result<(), String>
where T: Eq + Hash + Debug + FromStr, <T as FromStr>::Err: Debug,

Check that the list of (typesafe or string) IDs contains only unique IDs (no duplicates), and check that all of the IDs are NOT yet managed by the manager instance, i.e., they are fresh new values (this is important, for instance, when we need to add several new elements).

Specific manager class’ method to assert ID validity must be provided as assert_id_is_new.

Object Safety§

This trait is not object safe.

Implementors§