Skip to main content

SessionHooks

Trait SessionHooks 

Source
pub trait SessionHooks {
    type Model;
    type Event: Clone;

    // Required methods
    fn on_new(
        &self,
        params: &HashMap<String, String>,
    ) -> Result<Self::Model, String>;
    fn on_open(&self, path: &str) -> Result<Self::Model, String>;
    fn on_save(&self, model: &Self::Model, path: &str) -> Result<(), String>;
    fn on_rebuild_indices(&self, model: &mut Self::Model);
    fn get_digest(&self, model: &Self::Model) -> String;
    fn reverse(&self, event: &Self::Event, model: &mut Self::Model);
    fn replay(&self, event: &Self::Event, model: &mut Self::Model);
}
Expand description

Lifecycle hooks that a domain must implement.

Required Associated Types§

Source

type Model

The model type for this domain.

Source

type Event: Clone

The event type for undo/redo.

Required Methods§

Source

fn on_new( &self, params: &HashMap<String, String>, ) -> Result<Self::Model, String>

Creates a new empty model with the given params.

Source

fn on_open(&self, path: &str) -> Result<Self::Model, String>

Opens a model from a file path.

Source

fn on_save(&self, model: &Self::Model, path: &str) -> Result<(), String>

Saves a model to a file path.

Source

fn on_rebuild_indices(&self, model: &mut Self::Model)

Rebuilds derived indices after undo/redo.

Source

fn get_digest(&self, model: &Self::Model) -> String

Returns a compact digest string for drift detection.

Source

fn reverse(&self, event: &Self::Event, model: &mut Self::Model)

Reverses a single event on the model (for undo).

Source

fn replay(&self, event: &Self::Event, model: &mut Self::Model)

Replays a single event on the model (for redo).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§