pub struct PropertyManager {
    dyn_properties: HashMap<DynPropertyId, DynProperty>,
    stat_properties: HashMap<StatPropertyId, StatProperty>,
}
Expand description

Class to manage all properties of the sketch.

PropertyManager can be managed through its classical Rust API, as well as through the external events (as it implements the SessionState trait).

Fields§

§dyn_properties: HashMap<DynPropertyId, DynProperty>§stat_properties: HashMap<StatPropertyId, StatProperty>

Implementations§

source§

impl PropertyManager

Methods for safely generating new valid (unique) instances of identifiers for the current PropertyManager.

source

pub fn generate_dyn_property_id( &self, ideal_id: &str, start_index: Option<usize>, ) -> DynPropertyId

Generate valid DynPropertyId that’s currently not used by any dynamic property in this PropertyManager.

First, the given ideal_id or its transformation by replacing invalid characters are tried. If they are both invalid (non-unique), a numerical identifier is added at the end. By specifying start_index, the index search starts directly at that number (e.g., when ideal ID is “prop” and start index is 3, search for ID starts with “prop_3”, “prop_4”, …)

Warning: Do not use this to pre-generate more than one id at a time, as the process is deterministic and might generate the same IDs. Always generate an Id, add that property, and then repeat for other properties.

source

pub fn generate_stat_property_id( &self, ideal_id: &str, start_index: Option<usize>, ) -> StatPropertyId

Generate valid StatPropertyId that’s currently not used by any static property in this PropertyManager.

First, the given ideal_id or its transformation by replacing invalid characters are tried. If they are both invalid (non-unique), a numerical identifier is added at the end. By specifying start_index, the index search starts directly at that number (e.g., when ideal ID is “prop” and start index is 3, search for ID starts with “prop_3”, “prop_4”, …)

Warning: Do not use this to pre-generate more than one id at a time, as the process is deterministic and might generate the same IDs. Always generate an Id, add that property, and then repeat for other properties.

source§

impl PropertyManager

Creating new instances of PropertyManager.

source

pub fn new_empty() -> PropertyManager

Instantiate PropertyManager with empty sets of properties.

source

pub fn new_from_properties( dyn_properties: Vec<(&str, DynProperty)>, stat_properties: Vec<(&str, StatProperty)>, ) -> Result<PropertyManager, String>

Instantiate PropertyManager with dynamic and static properties given as a list of ID-property pairs.

source§

impl PropertyManager

Editing PropertyManager.

source

pub fn add_dynamic( &mut self, id: DynPropertyId, prop: DynProperty, ) -> Result<(), String>

Add pre-generated dynamic property.

source

pub fn add_dynamic_by_str( &mut self, id: &str, prop: DynProperty, ) -> Result<(), String>

Add pre-generated dynamic property with id given by str.

source

pub fn add_static( &mut self, id: StatPropertyId, prop: StatProperty, ) -> Result<(), String>

Add pre-generated static property.

source

pub fn add_static_by_str( &mut self, id: &str, prop: StatProperty, ) -> Result<(), String>

Add pre-generated static property with id given by str.

source

pub fn set_dyn_name( &mut self, id: &DynPropertyId, new_name: &str, ) -> Result<(), String>

Set name for given dynamic property.

source

pub fn set_stat_name( &mut self, id: &StatPropertyId, new_name: &str, ) -> Result<(), String>

Set name for given static property.

source

pub fn set_dyn_dataset( &mut self, id: &DynPropertyId, new_dataset: DatasetId, ) -> Result<(), String>

Update dynamic property’s sub-field dataset where applicable. If not applicable, return Err.

source

pub fn set_dyn_observation( &mut self, id: &DynPropertyId, new_obs: ObservationId, ) -> Result<(), String>

Update dynamic property’s sub-field observation where applicable. If not applicable, return Err.

source

pub fn set_dyn_formula( &mut self, id: &DynPropertyId, new_formula: &str, ) -> Result<(), String>

Update generic dynamic property’s formula. If not applicable (different variant), return Err.

source

pub fn set_dyn_none_observation( &mut self, id: &DynPropertyId, ) -> Result<(), String>

Update dynamic property’s sub-field observation to None where applicable. If not applicable, return Err.

source

pub fn set_dyn_attr_count( &mut self, id: &DynPropertyId, minimal: usize, maximal: usize, ) -> Result<(), String>

Update dynamic property’s sub-fields, if the property is of AttractorCount variant. If not applicable, return Err.

source

pub fn set_dyn_trap_space_details( &mut self, id: &DynPropertyId, is_minimal: bool, non_percolable: bool, ) -> Result<(), String>

Update dynamic property’s sub-fields, if the property is of ExistsTrapSpace variant. If not applicable, return Err.

source

pub fn set_stat_formula( &mut self, id: &StatPropertyId, new_formula: &str, ) -> Result<(), String>

Update generic static property’s formula. If not applicable (different variant), return Err.

source

pub fn set_stat_input_var( &mut self, id: &StatPropertyId, new_var: VarId, ) -> Result<(), String>

Update static property’s sub-field for input variable (of an update fn), where applicable. If not applicable, return Err.

source

pub fn set_stat_input_index( &mut self, id: &StatPropertyId, new_idx: usize, ) -> Result<(), String>

Update static property’s sub-field for index of input (of an uninterpreted fn), where applicable. If not applicable, return Err.

source

pub fn set_stat_target_fn( &mut self, id: &StatPropertyId, new_target: UninterpretedFnId, ) -> Result<(), String>

Update static property’s sub-field for target uninterpreted fn, where applicable. If not applicable, return Err.

source

pub fn set_stat_target_var( &mut self, id: &StatPropertyId, new_target: VarId, ) -> Result<(), String>

Update static property’s sub-field for target variable, where applicable. If not applicable, return Err.

source

pub fn set_stat_monotonicity( &mut self, id: &StatPropertyId, monotonicity: Monotonicity, ) -> Result<(), String>

Update static property’s sub-field for monotonicity, where applicable. If not applicable, return Err.

source

pub fn set_stat_essentiality( &mut self, id: &StatPropertyId, essentiality: Essentiality, ) -> Result<(), String>

Update static property’s sub-field for essentiality, where applicable. If not applicable, return Err.

source

pub fn set_stat_context( &mut self, id: &StatPropertyId, context: String, ) -> Result<(), String>

Update static property’s sub-field for context, where applicable. If not applicable, return Err.

source

pub fn swap_dyn_content( &mut self, id: &DynPropertyId, new_content: DynProperty, ) -> Result<(), String>

Swap content of a dynamic property with given id. The ID must be valid identifier. The variant of the prop. must stay the same (i.e., we only change attributes, not variant).

source

pub fn swap_dyn_content_by_str( &mut self, id: &str, new_content: DynProperty, ) -> Result<(), String>

Swap content of a dynamic property with given id. The ID must be valid identifier. The variant of the prop. must stay the same (i.e., we only change attributes, not variant).

source

pub fn swap_stat_content( &mut self, id: &StatPropertyId, new_content: StatProperty, ) -> Result<(), String>

Swap content of a static property with given id. The ID must be valid identifier. The variant of the prop. must stay the same (i.e., we only change attributes, not variant).

source

pub fn swap_stat_content_by_str( &mut self, id: &str, new_content: StatProperty, ) -> Result<(), String>

Swap content of a static property with given id. The ID must be valid identifier. The variant of the prop. must stay the same (i.e., we only change attributes, not variant).

source

pub fn set_dyn_id( &mut self, original_id: &DynPropertyId, new_id: DynPropertyId, ) -> Result<(), String>

Change ID of a dynamic property.

source

pub fn set_dyn_id_by_str( &mut self, original_id: &str, new_id: &str, ) -> Result<(), String>

Change ID of a dynamic property, with IDs given as string slices.

source

pub fn set_stat_id( &mut self, original_id: &StatPropertyId, new_id: StatPropertyId, ) -> Result<(), String>

Change ID of a static property.

source

pub fn set_stat_id_by_str( &mut self, original_id: &str, new_id: &str, ) -> Result<(), String>

Change ID of a static property, with IDs given as string slices.

source

pub fn remove_dynamic(&mut self, id: &DynPropertyId) -> Result<(), String>

Remove dynamic property.

source

pub fn remove_static(&mut self, id: &StatPropertyId) -> Result<(), String>

Remove static property.

source

pub fn make_generated_reg_prop_ids_consistent(&mut self)

Go through all static properties that are automatically generated from the regulation graph and make their IDs consistent with the variables they reference.

This is useful after we change the variable’s ID, e.g., to ensure that monotonicity properties still have IDs like monotonicity_REGULATOR_TARGET.

source§

impl PropertyManager

Internal assertion utilities.

source

fn assert_no_dynamic(&self, id: &DynPropertyId) -> Result<(), String>

(internal) Utility method to ensure there is no dynamic property with given ID yet.

source

fn assert_valid_dynamic(&self, id: &DynPropertyId) -> Result<(), String>

(internal) Utility method to ensure there is a dynamic property with given ID.

source

fn assert_no_static(&self, id: &StatPropertyId) -> Result<(), String>

(internal) Utility method to ensure there is no static property with given ID yet.

source

fn assert_valid_static(&self, id: &StatPropertyId) -> Result<(), String>

(internal) Utility method to ensure there is a static property with given ID.

source§

impl PropertyManager

Observing the PropertyManager.

source

pub fn num_dyn_properties(&self) -> usize

The number of dynamic properties in this PropertyManager.

source

pub fn num_stat_properties(&self) -> usize

The number of static properties in this PropertyManager.

source

pub fn is_valid_dyn_property_id(&self, id: &DynPropertyId) -> bool

Check if there is a dynamic property with given Id.

source

pub fn is_valid_stat_property_id(&self, id: &StatPropertyId) -> bool

Check if there is a static property with given Id.

source

pub fn dyn_props(&self) -> DynPropIterator<'_>

Return an iterator over all dynamic properties of this model.

source

pub fn stat_props(&self) -> StatPropIterator<'_>

Return an iterator over all dynamic properties of this model.

source

pub fn get_dyn_prop_id(&self, id: &str) -> Result<DynPropertyId, String>

Return a valid dynamic property’s DynPropertyId corresponding to the given str id.

Return Err if such property does not exist (and the ID is invalid).

source

pub fn get_dyn_prop(&self, id: &DynPropertyId) -> Result<&DynProperty, String>

Return a DynProperty corresponding to a given DynPropertyId.

Return Err if such dynamic property does not exist (the ID is invalid in this context).

source

pub fn get_stat_prop_id(&self, id: &str) -> Result<StatPropertyId, String>

Return a valid static property’s StatPropertyId corresponding to the given str id.

Return Err if such property does not exist (and the ID is invalid).

source

pub fn get_stat_prop( &self, id: &StatPropertyId, ) -> Result<&StatProperty, String>

Return a StatProperty corresponding to a given StatPropertyId.

Return Err if such static property does not exist (the ID is invalid in this context).

source§

impl PropertyManager

Implementation for events related to modifying dynamic properties.

source

pub(super) fn event_add_dynamic( &mut self, event: &Event, ) -> Result<Consumed, DynError>

Perform event of adding a new dynamic property to this PropertyManager.

source

pub(super) fn event_add_default_dynamic( &mut self, event: &Event, ) -> Result<Consumed, DynError>

Perform event of adding a new DEFAULT dynamic property of given variant to this PropertyManager.

source

pub(super) fn event_modify_dynamic( &mut self, event: &Event, at_path: &[&str], prop_id: DynPropertyId, ) -> Result<Consumed, DynError>

Perform event of modifying or removing existing dynamic property of this PropertyManager.

source§

impl PropertyManager

Implementation for events related to modifying static properties.

source

pub(super) fn event_add_static( &mut self, event: &Event, ) -> Result<Consumed, DynError>

Perform event of adding a new static property to this PropertyManager.

source

pub(super) fn event_add_default_static( &mut self, event: &Event, ) -> Result<Consumed, DynError>

Perform event of adding a new DEFAULT static property of given variant to this PropertyManager.

source

pub(super) fn event_modify_static( &mut self, event: &Event, at_path: &[&str], prop_id: StatPropertyId, ) -> Result<Consumed, DynError>

Perform event of modifying or removing existing static property of this PropertyManager.

Trait Implementations§

source§

impl Clone for PropertyManager

source§

fn clone(&self) -> PropertyManager

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for PropertyManager

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for PropertyManager

source§

fn default() -> PropertyManager

Default manager instance with no datasets.

source§

impl Manager for PropertyManager

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). Read more
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). Read more
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). Read more
source§

impl PartialEq for PropertyManager

source§

fn eq(&self, other: &PropertyManager) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SessionHelper for PropertyManager

source§

fn starts_with<'a, 'b>( prefix: &str, at_path: &'a [&'b str], ) -> Option<&'a [&'b str]>

A utility function which checks if at_path starts with a specific first segment. If yes, returns the remaining part of the path.
source§

fn matches(expected: &[&str], at_path: &[&str]) -> bool

A utility function which checks if at_path is exactly
source§

fn invalid_path_error_generic<T>(at_path: &[&str]) -> Result<T, DynError>

A utility function which emits a generic “invalid path” error.
source§

fn invalid_path_error_specific<T>( path: &[&str], component: &str, ) -> Result<T, DynError>

A utility function which emits a “invalid path” error mentioning specific state’s component.
source§

fn clone_payload_str(event: &Event, component: &str) -> Result<String, DynError>

A utility function to get and clone a payload of an event. Errors if payload is empty. Read more
source§

fn assert_path_length( path: &[&str], length: usize, component: &str, ) -> Result<(), DynError>

A utility function to assert that path has a given length, or emit a DynError otherwise. Read more
source§

fn assert_payload_empty(event: &Event, component: &str) -> Result<(), DynError>

A utility function to assert that payload is empty - otherwise, DynError is emitted. Read more
source§

impl SessionState for PropertyManager

source§

fn perform_event( &mut self, event: &Event, at_path: &[&str], ) -> Result<Consumed, DynError>

Modify the session state using the provided event. The possible outcomes are described by Consumed.
source§

fn refresh( &self, full_path: &[String], at_path: &[&str], ) -> Result<Event, DynError>

“Read” session state into an event without modifying it.
source§

impl StructuralPartialEq for PropertyManager

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> UserEvent for T
where T: Debug + Clone + Send + 'static,