pub trait Model: Sized {
type Msg: Send + 'static;
// Required methods
fn update(&mut self, msg: Self::Msg) -> Command<Self::Msg>;
fn view(&self, frame: &mut Frame<'_>);
fn handle_event(&self, event: Event) -> Option<Self::Msg>;
// Provided methods
fn init(&self) -> Command<Self::Msg> { ... }
fn register_ontology(&self, _registry: &mut OntologyRegistry) { ... }
}Expand description
The core trait for application models (Elm Architecture).
Required Associated Types§
Required Methods§
Sourcefn update(&mut self, msg: Self::Msg) -> Command<Self::Msg>
fn update(&mut self, msg: Self::Msg) -> Command<Self::Msg>
Handle an event and return an updated model plus optional command.
Sourcefn handle_event(&self, event: Event) -> Option<Self::Msg>
fn handle_event(&self, event: Event) -> Option<Self::Msg>
Convert a raw terminal event into an application message.
Return None to ignore the event.
Provided Methods§
Sourcefn register_ontology(&self, _registry: &mut OntologyRegistry)
fn register_ontology(&self, _registry: &mut OntologyRegistry)
Called when the agent ontology is exported. Override to customize the registry.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".