Trait ComposableState

Source
pub trait ComposableState {
    type ParentState: Serialize + DeserializeOwned + Clone + Debug;
    type Summary: Serialize + DeserializeOwned + Clone + Debug;
    type Delta: Serialize + DeserializeOwned + Clone + Debug;
    type Parameters: Serialize + DeserializeOwned + Clone + Debug;

    // Required methods
    fn verify(
        &self,
        parent_state: &Self::ParentState,
        parameters: &Self::Parameters,
    ) -> Result<(), String>;
    fn summarize(
        &self,
        parent_state: &Self::ParentState,
        parameters: &Self::Parameters,
    ) -> Self::Summary;
    fn delta(
        &self,
        parent_state: &Self::ParentState,
        parameters: &Self::Parameters,
        old_state_summary: &Self::Summary,
    ) -> Option<Self::Delta>;
    fn apply_delta(
        &mut self,
        parent_state: &Self::ParentState,
        parameters: &Self::Parameters,
        delta: &Option<Self::Delta>,
    ) -> Result<(), String>;

    // Provided method
    fn merge(
        &mut self,
        parent_state: &Self::ParentState,
        parameters: &Self::Parameters,
        other_state: &Self,
    ) -> Result<(), String> { ... }
}

Required Associated Types§

Required Methods§

Source

fn verify( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Result<(), String>

Source

fn summarize( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, ) -> Self::Summary

Source

fn delta( &self, parent_state: &Self::ParentState, parameters: &Self::Parameters, old_state_summary: &Self::Summary, ) -> Option<Self::Delta>

Source

fn apply_delta( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, delta: &Option<Self::Delta>, ) -> Result<(), String>

Applies the specified delta to the current state.

If delta is None then this function should still make any changes that might be required based on other fields in the parent_state which may have changed.

Provided Methods§

Source

fn merge( &mut self, parent_state: &Self::ParentState, parameters: &Self::Parameters, other_state: &Self, ) -> Result<(), String>

Merges the current state with another state.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§