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) { ... }
fn title(&self) -> &str { ... }
fn subscriptions(&self) -> Vec<Subscription<Self::Msg>> { ... }
fn current_route(&self) -> &str { ... }
}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 a message 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 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.
Sourcefn subscriptions(&self) -> Vec<Subscription<Self::Msg>>
fn subscriptions(&self) -> Vec<Subscription<Self::Msg>>
Return subscriptions for this model. Called after each update.
Sourcefn current_route(&self) -> &str
fn current_route(&self) -> &str
Return the current route. Override for multi-page apps.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".