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§
Required Methods§
Sourcefn on_new(
&self,
params: &HashMap<String, String>,
) -> Result<Self::Model, String>
fn on_new( &self, params: &HashMap<String, String>, ) -> Result<Self::Model, String>
Creates a new empty model with the given params.
Sourcefn on_save(&self, model: &Self::Model, path: &str) -> Result<(), String>
fn on_save(&self, model: &Self::Model, path: &str) -> Result<(), String>
Saves a model to a file path.
Sourcefn on_rebuild_indices(&self, model: &mut Self::Model)
fn on_rebuild_indices(&self, model: &mut Self::Model)
Rebuilds derived indices after undo/redo.
Sourcefn get_digest(&self, model: &Self::Model) -> String
fn get_digest(&self, model: &Self::Model) -> String
Returns a compact digest string for drift detection.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".